x/tools/go/packages: returns wrong package name when overlay has a new package name #38328
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
go version go1.14.1 darwin/amd64
Here's what happens when packages.Load is called with an overlay that has a different package name than the file on disk. (sorry about the long directory names) Line 5 shows that the file on disk is package foo, line 6 shows that the overlay for that file is package foox, and line 8 shows that Load returned package foo, not package foox.
view.go:810: packages.Load patterns=[file=/var/folders/72/mj6w6gyj5dn6yp_2_tlbdwym00052r/T/zfake439024600/foo.go]
view.go:811: config: mode:LoadMode(NeedName|NeedFiles|NeedCompiledGoFiles|NeedImports|NeedDeps|NeedTypesSizes) dir:/var/folders/72/mj6w6gyj5dn6yp_2_tlbdwym00052r/T/zfake439024600
view.go:812: Contents of dir:
view.go:826: file go.mod contains "module fake"
view.go:826: file foo.go contains "package foo\n\nimport "fmt"\n\nfunc proc() {\n\tfmt.Print("hi")\n}\n"
view.go:830: Overlay[/var/folders/72/mj6w6gyj5dn6yp_2_tlbdwym00052r/T/zfake439024600/foo.go]="package foox\n\nimport "fmt"\n\nfunc proc() {\n\tfmt.Print("hi")\n}\n"
view.go:832: cfg.BuildFlags [-modfile=/var/folders/72/mj6w6gyj5dn6yp_2_tlbdwym00052r/T/go.zfake439024600.599675223.mod]
view.go:835: Load returns pkgs: foo errors:[]
this is the cause of #32149
https://github.com/golang/go/issues/32149
The text was updated successfully, but these errors were encountered: