Add gochecksumtype and check Name in .../schema/ast/ast.go #121
+3
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
gochecksumtype is a linter in golangci-lint that checks for switch statement exhaustiveness for types that look like sum types in other languages. More precisely, interface types with a //sumtype:decl annotation and an unexported nullary marker method are statically guaranteed to be closed (since new types that implement the interface can't be created). This means that we can check for exhaustiveness on type switches for values implementing the sumdecl-compatible interface, which is what the linter does.
The initial attempt to add this to every type with a marker interface #111 has grown in complexity since a few of the tests use unknownNode and unknownType types for checking the error paths. gochecksumtype has no way of indicating test-only variants of a sum type. So, to keep the diff size small and the code coverage at 100% (except for the generated parser) at each step, I'm going to break PR #111 into pieces and land them separately.