diff options
| author | Robert Griesemer <gri@golang.org> | 2023-04-18 16:43:11 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-04-19 14:07:00 +0000 |
| commit | d93f02010cbaa83916eecb4fb23dfc4153694dc0 (patch) | |
| tree | 32a4fba26064c31e63d4843753daf166ea9b8ae2 /test/fixedbugs | |
| parent | 522eace4ca496626bcb3b65f9dcb6e8db2673fed (diff) | |
| download | go-d93f02010cbaa83916eecb4fb23dfc4153694dc0.tar.xz | |
cmd/compile/internal/types2: only mark variables as used if they are
Marking variables in erroneous variable declarations as used is
convenient for tests but doesn't necessarily hide follow-on errors
in real code: either the variable is not supposed to be declared in
the first place and then we should get an error if it is not used,
or it is there because it is intended to be used, and the we expect
an error it if is not used.
This brings types2 closer to go/types.
Change-Id: If7ee1298fc770f7ad0cefe7e968533fd50ec2343
Reviewed-on: https://go-review.googlesource.com/c/go/+/486175
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'test/fixedbugs')
| -rw-r--r-- | test/fixedbugs/issue30085.go | 2 | ||||
| -rw-r--r-- | test/fixedbugs/issue30087.go | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/test/fixedbugs/issue30085.go b/test/fixedbugs/issue30085.go index 512355a443..f8595ab90c 100644 --- a/test/fixedbugs/issue30085.go +++ b/test/fixedbugs/issue30085.go @@ -9,5 +9,5 @@ package main func main() { var c, d = 1, 2, 3 // ERROR "assignment mismatch: 2 variables but 3 values|wrong number of initializations|extra init expr" var e, f, g = 1, 2 // ERROR "assignment mismatch: 3 variables but 2 values|wrong number of initializations|missing init expr" - _, _, _, _ = c, d, e, f + _, _, _, _, _ = c, d, e, f, g } diff --git a/test/fixedbugs/issue30087.go b/test/fixedbugs/issue30087.go index 3e4b0324a3..c55c47b064 100644 --- a/test/fixedbugs/issue30087.go +++ b/test/fixedbugs/issue30087.go @@ -11,5 +11,5 @@ func main() { _ = 1, 2 // ERROR "assignment mismatch: 1 variable but 2 values|number of variables does not match|cannot assign" c, d := 1 // ERROR "assignment mismatch: 2 variables but 1 value|wrong number of initializations|cannot initialize" e, f := 1, 2, 3 // ERROR "assignment mismatch: 2 variables but 3 values|wrong number of initializations|cannot initialize" - _, _, _, _ = c, d, e, f + _, _, _, _, _, _ = a, b, c, d, e, f } |
