exhaustive icon indicating copy to clipboard operation
exhaustive copied to clipboard

superfluous type conversion in case clause results in a false positive report

Open nishanths opened this issue 2 years ago • 0 comments

type M int

const (
	A M = iota
	B
)

func quux(v M) {
	switch v {
	case M(A):
	}
}

For the program above, exhaustive currently incorrectly reports:

missing cases in switch of type M: A, B

However, it should only report B as missing:

missing cases in switch of type M: B

Notes

The issue is that exhaustive seems to be confused by the (superfluous) type conversion in case M(A): . If it were just case A:, exhaustive correctly reports only B as missing:

missing cases in switch of type M: B

nishanths avatar Jun 03 '22 06:06 nishanths