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

QF1011 gets untyped constants wrong #1071

Closed
dominikh opened this issue Aug 19, 2021 · 0 comments
Closed

QF1011 gets untyped constants wrong #1071

dominikh opened this issue Aug 19, 2021 · 0 comments

Comments

@dominikh
Copy link
Owner

For

package main

const X = 1

func main() {
	var _ uint = X
}

we currently emit

sand.go:6:8: could omit type uint from declaration; it will be inferred from the right-hand side (QF1011)

which is clearly wrong. X is an untyped constant, and without the explicit uint, it will default to int.

The issue lies with how we check the type of the RHS. The type-checker "helpfully" types that use of X for us, based on its context.

(This bug feels very familiar, I think we've fixed pretty much the same issue in another check recently.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant