Skip to content

Commit

Permalink
add bugs section in readme for type parameter switch statements
Browse files Browse the repository at this point in the history
  • Loading branch information
nishanths committed Jun 3, 2022
1 parent c85349a commit 640ad10
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ The package provides an `Analyzer` that follows the guidelines in the
[`go/analysis`][3] package; this should make it possible to integrate
exhaustive with your own analysis driver program.

## Bugs

`exhaustive` does not report missing cases if the switch statement
switches on a type parameterized type. See [this
issue](https://github.com/nishanths/exhaustive/issues/31) for details.

## Example

Given the enum
Expand Down
32 changes: 32 additions & 0 deletions testdata/xxx/typeparam/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package typeparam

// Testing instructions:
// $ go build ./cmd/exhaustive
// $ ./exhaustive ./testdata/xxx/typeparam

type M int

const (
A M = iota
B
)

type N uint

const (
C N = iota
D
)

func foo[T M](v T) {
switch v {
case T(A):
}
}

func bar[T M | N](v T) {
switch v {
case T(A):
case T(D):
}
}

0 comments on commit 640ad10

Please sign in to comment.