You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
_ "golang.org/x/tools/go/gcimporter"
"golang.org/x/tools/go/types"
)
func foo() {
var x int
func() {
x = 1
}()
}
func main() {
fset := token.NewFileSet()
file, err := parser.ParseFile(fset, "./repro.go", nil, 0)
if err != nil {
panic(err)
}
_, err = types.Check("repro", fset, []*ast.File{file})
fmt.Println("error:", err)
}
If you place it in $GOPATH/src/repro/repro.go then you can build it with gc (go version 1.4), but if you run it, golang.org/x/tools/go/types (most recent tip at time of issue report) fails to type check.
It seems like they disagree on if x is considered to be used or not.
The text was updated successfully, but these errors were encountered:
I appreciate that the behavior that gc is doing here is a dupe of #3059 but the more important part in my opinion is that go/types disagrees and considers it an error. It doesn't look like #3059 has that information. Where should that issue be tracked, or is that not an issue because this is implementation defined in the spec?
I agree. I'll just leave a comment on the other ticket describing the pain I experienced due to this to maybe help prioritize fixing it since it's not obvious how cmd/gc accepting these programs is harmful.
Consider this program:
If you place it in
$GOPATH/src/repro/repro.go
then you can build it with gc (go version 1.4), but if you run it, golang.org/x/tools/go/types (most recent tip at time of issue report) fails to type check.It seems like they disagree on if x is considered to be used or not.
The text was updated successfully, but these errors were encountered: