]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] cmd/compile/internal/types2: fix types2 panic
authorMatthew Dempsky <mdempsky@google.com>
Mon, 17 May 2021 17:50:41 +0000 (10:50 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 19 May 2021 06:26:44 +0000 (06:26 +0000)
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>
src/cmd/compile/internal/types2/resolver.go
test/run.go

index fa30650bd444f3d995b1939e897783e6ef50b768..ef49a8b48dab1e0f3e4716dbc36b0303e496709f 100644 (file)
@@ -265,7 +265,7 @@ func (check *Checker) collectObjects() {
                                }
 
                                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
                                }
 
index d64affb772b4aee225ae691f79e4a699e17e2e86..506380a7a5a4b4d2a60751ce73e1307b19cc19ec 100644 (file)
@@ -2091,7 +2091,6 @@ var excludedFiles = map[string]bool{
        "fixedbugs/issue42058b.go": true, // types2 doesn't report "channel element type too large"
        "fixedbugs/issue4232.go":   true, // types2 reports (correct) extra errors
        "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/issue4510.go":   true, // types2 reports different (but ok) line numbers
        "fixedbugs/issue5609.go":   true, // types2 needs a better error message