aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/typexpr.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2020-12-09 19:15:15 -0800
committerRobert Griesemer <gri@golang.org>2020-12-14 21:27:49 +0000
commitdf58f3368e62fbc290b419f0b33b97a984b9ca19 (patch)
tree44b9d903ab143737900f2c51359a1372911ad536 /src/cmd/compile/internal/types2/typexpr.go
parent91803a2df334ddfc9377ef4d07cc5f0eff51b6a2 (diff)
downloadgo-df58f3368e62fbc290b419f0b33b97a984b9ca19.tar.gz
go-df58f3368e62fbc290b419f0b33b97a984b9ca19.zip
[dev.typeparams] cmd/compile/internal/types2: don't report two errors for bad strings
If the parser reported an error for (string) literals, don't report a second error during type checking. This should have a couple of tests but they are tricky to arrange with the current testing framework as the ERROR comment cannot be on the line where the string. But the change is straightforward and we have test/fixedbugs/issue32133.go that is passing now. Change-Id: I0cd7f002b04e4092b8eb66009c7413288c8bfb23 Reviewed-on: https://go-review.googlesource.com/c/go/+/277993 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/types2/typexpr.go')
-rw-r--r--src/cmd/compile/internal/types2/typexpr.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/types2/typexpr.go b/src/cmd/compile/internal/types2/typexpr.go
index 39bb3a6b14..22df01b3be 100644
--- a/src/cmd/compile/internal/types2/typexpr.go
+++ b/src/cmd/compile/internal/types2/typexpr.go
@@ -1045,7 +1045,8 @@ func (a byUniqueMethodName) Less(i, j int) bool { return a[i].Id() < a[j].Id() }
func (a byUniqueMethodName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (check *Checker) tag(t *syntax.BasicLit) string {
- if t != nil {
+ // If t.Bad, an error was reported during parsing.
+ if t != nil && !t.Bad {
if t.Kind == syntax.StringLit {
if val, err := strconv.Unquote(t.Value); err == nil {
return val