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

go/types: don't skip checking of RangeStmt.Body because of errors in loop vars #10148

Closed
alandonovan opened this issue Mar 12, 2015 · 1 comment

Comments

@alandonovan
Copy link
Contributor

Type checking doesn't enter the body of the third loop because the range operand has the wrong type and the var y was declared with := not assigned with =. It should probably try harder; e.g., declare the variable y with type Invalid. (See also Google internal bug #19639588.)

package main

func main() {
for y := range "" {
_ = "" + 1 // type error => body was type-checked
}
for range 1 {
_ = "" + 1 // type error => body was type-checked
}
for y := range 1 {
_ = "" + 1 // no type error => body not type-checked
}
}

@griesemer
Copy link
Contributor

This issue was closed by golang/tools@e4a1c78 .

@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants