1
0
mirror of https://github.com/golang/go synced 2024-11-17 06:54:48 -07:00

[dev.typeparams] cmd/compile/internal/types2: fix types2 panic

When reporting a "cannot import package as init" error, we can't rely
on s.LocalPkgName being non-nil, as the original package's name may
already be nil.

Change-Id: Idec006780f12ee4398501d05a5b2ed13157f88ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/320490
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Matthew Dempsky 2021-05-17 10:50:41 -07:00
parent c81562d99f
commit fc9e64cc98
2 changed files with 1 additions and 2 deletions

View File

@ -265,7 +265,7 @@ func (check *Checker) collectObjects() {
} }
if name == "init" { if name == "init" {
check.error(s.LocalPkgName, "cannot import package as init - init must be a func") check.error(s, "cannot import package as init - init must be a func")
continue continue
} }

View File

@ -2091,7 +2091,6 @@ var excludedFiles = map[string]bool{
"fixedbugs/issue42058b.go": true, // types2 doesn't report "channel element type too large" "fixedbugs/issue42058b.go": true, // types2 doesn't report "channel element type too large"
"fixedbugs/issue4232.go": true, // types2 reports (correct) extra errors "fixedbugs/issue4232.go": true, // types2 reports (correct) extra errors
"fixedbugs/issue43479.go": true, // ICE in iexport due to Syms from the wrong package "fixedbugs/issue43479.go": true, // ICE in iexport due to Syms from the wrong package
"fixedbugs/issue43962.go": true, // types2 panics when importing package named "init"
"fixedbugs/issue4452.go": true, // types2 reports (correct) extra errors "fixedbugs/issue4452.go": true, // types2 reports (correct) extra errors
"fixedbugs/issue4510.go": true, // types2 reports different (but ok) line numbers "fixedbugs/issue4510.go": true, // types2 reports different (but ok) line numbers
"fixedbugs/issue5609.go": true, // types2 needs a better error message "fixedbugs/issue5609.go": true, // types2 needs a better error message