From fcb4a6205bdc6ce526f359ae5eae5fb6ded53916 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Mon, 4 Mar 2019 14:22:33 -0500 Subject: [PATCH] check: disable exhaustive checks in test files 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. --- main.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 1e1b25c..3fe51bf 100644 --- a/main.go +++ b/main.go @@ -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 {