Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

same name enum type in inner scope can produce incorrect diagnostic #23

Closed
nishanths opened this issue Nov 5, 2021 · 0 comments
Closed
Assignees

Comments

@nishanths
Copy link
Owner

Input like this currently produce an incorrect diagnostic.

package example

type T int

const (
	A T = iota
	B
)

func f() {
	type T int

	const (
		C T = iota
		D
	)
	
	var v T
	switch v {
	case C, D:
	}
}

The incorrect diagnostic is:

missing cases in switch of type T: A, B

Background

The analyzer only supports enum types that are at the package level. To lookup an enum type, it looks up a map using a string key equal to the enum type name. If an inner scope has a type of the same name, like in this example, it results in an incorrect diagnostic.

Next steps

It may be best to address this together with #11.

@nishanths nishanths self-assigned this Nov 5, 2021
@nishanths nishanths changed the title shadowed enum type in inner scope can produce incorrect diagnostic same name enum type in inner scope can produce incorrect diagnostic Nov 5, 2021
nishanths added a commit that referenced this issue Nov 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant