From aa5ff29dabbfdda036b8a1f5c5a80f239b876abc Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Thu, 25 Aug 2022 16:41:35 -0700 Subject: go/parser: adjustments to error messages - Use "expected X" rather then "expecting X". - Report a better error when a type argument list is expected. - Adjust various tests. For #54511. Change-Id: I0c5ca66ecbbdcae1a8f67377682aae6b0b6ab89a Reviewed-on: https://go-review.googlesource.com/c/go/+/425734 TryBot-Result: Gopher Robot Reviewed-by: Alan Donovan Run-TryBot: Robert Griesemer Reviewed-by: Robert Griesemer Auto-Submit: Robert Griesemer --- test/fixedbugs/issue13273.go | 8 ++++---- test/fixedbugs/issue18092.go | 2 +- test/fixedbugs/issue18747.go | 2 +- test/fixedbugs/issue19667.go | 2 +- test/fixedbugs/issue23664.go | 4 ++-- test/fixedbugs/issue33386.go | 10 +++++----- 6 files changed, 14 insertions(+), 14 deletions(-) (limited to 'test/fixedbugs') diff --git a/test/fixedbugs/issue13273.go b/test/fixedbugs/issue13273.go index 2498da4d47..ea729d6080 100644 --- a/test/fixedbugs/issue13273.go +++ b/test/fixedbugs/issue13273.go @@ -47,9 +47,9 @@ func f() { <-(<-chan (<-chan (<-chan (<-chan int))))(nil) <-(<-chan (<-chan (<-chan (<-chan (<-chan int)))))(nil) - type _ <-<-chan int // ERROR "unexpected <-, expecting chan|expected .*chan.*" - <-<-chan int // ERROR "unexpected <-, expecting chan|expecting {" (new parser: same error as for type decl) + type _ <-<-chan int // ERROR "unexpected <-, expected chan|expected .*chan.*" + <-<-chan int // ERROR "unexpected <-, expected chan|expecting {" (new parser: same error as for type decl) - type _ <-chan<-int // ERROR "unexpected int, expecting chan|expected .*chan.*|expecting chan|expected .*;.* or .*}.* or newline" - <-chan<-int // ERROR "unexpected int, expecting chan|expecting {" (new parser: same error as for type decl) + type _ <-chan<-int // ERROR "unexpected int, expected chan|expected .*chan.*|expected chan|expected .*;.* or .*}.* or newline" + <-chan<-int // ERROR "unexpected int, expected chan|expecting {" (new parser: same error as for type decl) } diff --git a/test/fixedbugs/issue18092.go b/test/fixedbugs/issue18092.go index a0f7eddda5..c8e60f31c5 100644 --- a/test/fixedbugs/issue18092.go +++ b/test/fixedbugs/issue18092.go @@ -11,5 +11,5 @@ func _() { select { default: case <-ch { // GCCGO_ERROR "expected colon" - } // GC_ERROR "expecting :" + } // GC_ERROR "expected :" } diff --git a/test/fixedbugs/issue18747.go b/test/fixedbugs/issue18747.go index fb8331fcc9..4eabe0e61d 100644 --- a/test/fixedbugs/issue18747.go +++ b/test/fixedbugs/issue18747.go @@ -23,6 +23,6 @@ func _ () { if ; foo {} - if foo // ERROR "unexpected newline, expecting { after if clause" + if foo // ERROR "unexpected newline, expected { after if clause" {} } diff --git a/test/fixedbugs/issue19667.go b/test/fixedbugs/issue19667.go index e33e350487..4b0925add2 100644 --- a/test/fixedbugs/issue19667.go +++ b/test/fixedbugs/issue19667.go @@ -10,4 +10,4 @@ package p func f() { if err := http.ListenAndServe( // GCCGO_ERROR "undefined name" -} // ERROR "unexpected }, expecting expression|expected operand|missing .*\)|expected .*;|expected .*{" +} // ERROR "unexpected }, expected expression|expected operand|missing .*\)|expected .*;|expected .*{" diff --git a/test/fixedbugs/issue23664.go b/test/fixedbugs/issue23664.go index 1925ebffe7..715654be70 100644 --- a/test/fixedbugs/issue23664.go +++ b/test/fixedbugs/issue23664.go @@ -9,9 +9,9 @@ package p func f() { - if f() true { // ERROR "unexpected true, expecting {" + if f() true { // ERROR "unexpected true, expected {" } - switch f() true { // ERROR "unexpected true, expecting {" + switch f() true { // ERROR "unexpected true, expected {" } } diff --git a/test/fixedbugs/issue33386.go b/test/fixedbugs/issue33386.go index 7b2f565285..a7074069fe 100644 --- a/test/fixedbugs/issue33386.go +++ b/test/fixedbugs/issue33386.go @@ -13,17 +13,17 @@ package p func _() { go func() { // no error here about goroutine send <- // GCCGO_ERROR "undefined name" - }() // ERROR "expecting expression|expected operand" + }() // ERROR "expected expression|expected operand" } func _() { defer func() { // no error here about deferred function 1 + // GCCGO_ERROR "value computed is not used" - }() // ERROR "expecting expression|expected operand" + }() // ERROR "expected expression|expected operand" } func _() { - _ = (1 +) // ERROR "expecting expression|expected operand" - _ = a[2 +] // ERROR "expecting expression|expected operand|undefined name" - _ = []int{1, 2, 3 + } // ERROR "expecting expression|expected operand" + _ = (1 +) // ERROR "expected expression|expected operand" + _ = a[2 +] // ERROR "expected expression|expected operand|undefined name" + _ = []int{1, 2, 3 + } // ERROR "expected expression|expected operand" } -- cgit v1.3