Skip to content

Commit

Permalink
check: disable exhaustive checks in test files
Browse files Browse the repository at this point in the history
It's not quite clear how to make it work. In cases where a package both
defines tests and a sum type, you wind up with multiple distinct
definitions of types that do not satisfy types.Identical, which in turn
results in inexhaustive errors. It's not quite clear how to fix this.
  • Loading branch information
BurntSushi committed Mar 4, 2019
1 parent f6a8b46 commit fcb4a62
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,18 @@ func run(pkgs []*packages.Package) []error {

func tycheckAll(args []string) ([]*packages.Package, error) {
conf := &packages.Config{
Mode: packages.LoadSyntax,
Tests: true,
Mode: packages.LoadSyntax,
// Unfortunately, it appears including the test packages in
// this lint makes it difficult to do exhaustiveness checking.
// Namely, it appears that compiling the test version of a
// package introduces distinct types from the normal version
// of the package, which will always result in inexhaustive
// errors whenever a package both defines a sum type and has
// tests. (Specifically, using `package name`. Using `package
// name_test` is OK.)
//
// It's not clear what the best way to fix this is. :-(
Tests: false,
}
pkgs, err := packages.Load(conf, args...)
if err != nil {
Expand Down

0 comments on commit fcb4a62

Please sign in to comment.