Skip to content

Commit

Permalink
doc: guarantee no new analytics related to type aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
nishanths committed Nov 11, 2021
1 parent e7c2fbf commit 481431f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions exhaustive.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ exported and unexported enum members must be listed to satisfy exhaustiveness.
For an enum type defined in an external package, it is sufficient that only
exported enum members are listed.
Only identifiers denoting constants and qualified identifiers denoting constants
listed in switch statement cases can contribute towards satisfying
exhaustiveness. Literal constant values, struct fields, etc. will not.
Identifiers denoting constants (e.g. Tundra) and qualified identifiers denoting
constants (e.g. somepkg.Grassland) listed in a switch statement's cases can
contribute towards satisfying exhaustiveness. Literal constant values, fields in
a struct value, etc. will not.
Type aliases
Expand Down Expand Up @@ -78,6 +79,11 @@ It is worth noting that, though T1 and T2 are identical types, only constants
declared in the same scope as type T2's scope can be T2's enum members. In the
example, otherpkg.A and otherpkg.B are T2's enum members.
The analyzer guarantees that introducing a type alias (such as type T1 =
otherpkg.T2) will never result in new diagnostics from the analyzer, as long as
the set of enum member constant values of the new RHS type (otherpkg.T2) is a
subset of the set of enu member constant values of the old LHS type (T1).
Advanced notes
Recall from an earlier section that for a constant to be an enum member for an
Expand Down

0 comments on commit 481431f

Please sign in to comment.