]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.17] go/types: fix panic with nil package name
authorRob Findley <rfindley@google.com>
Thu, 3 Jun 2021 13:52:05 +0000 (09:52 -0400)
committerCherry Mui <cherryyz@google.com>
Wed, 1 Sep 2021 22:31:06 +0000 (22:31 +0000)
This is a straightforward port of CL 320490 to go/types.

Fixes #48082

Change-Id: I763c806c777f926a563d8f9384764e5b3f7f083c
Reviewed-on: https://go-review.googlesource.com/c/go/+/324732
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
(cherry picked from commit e32fab145b488cf8bd1fb4a2466cb9be33ac3770)
Reviewed-on: https://go-review.googlesource.com/c/go/+/347071

src/go/types/resolver.go

index 114647a2fffecb937bd785c3d85e3467626499a4..4892218b75453cd8cc2f539a74e0269df4bc785c 100644 (file)
@@ -276,7 +276,7 @@ func (check *Checker) collectObjects() {
                                }
 
                                if name == "init" {
-                                       check.errorf(d.spec.Name, _InvalidInitDecl, "cannot import package as init - init must be a func")
+                                       check.errorf(d.spec, _InvalidInitDecl, "cannot import package as init - init must be a func")
                                        return
                                }