diff options
author | Robert Griesemer <gri@golang.org> | 2019-08-29 17:34:17 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2019-09-10 03:10:11 +0000 |
commit | cdd2c265cc132a15e20298fbb083a70d7f3b495d (patch) | |
tree | e20c047946a710a4f9a451f44a631bbc745bcf02 /src/cmd/compile/internal/syntax/scanner_test.go | |
parent | a2cf16d42cd4feb1c25c58097ab05d786119f15e (diff) | |
download | go-cdd2c265cc132a15e20298fbb083a70d7f3b495d.tar.gz go-cdd2c265cc132a15e20298fbb083a70d7f3b495d.zip |
cmd/compile/internal/scanner: report at most one lexical error per number literal
Leave reporting of multiple errors for strings alone for now;
we probably want to see all incorrect escape sequences in
runes/strings independent of other errors.
Fixes #33961.
Change-Id: Id722e95f802687963eec647d1d1841bd6ed17d35
Reviewed-on: https://go-review.googlesource.com/c/go/+/192499
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/syntax/scanner_test.go')
-rw-r--r-- | src/cmd/compile/internal/syntax/scanner_test.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/syntax/scanner_test.go b/src/cmd/compile/internal/syntax/scanner_test.go index 3030bfd4c0..717deb9073 100644 --- a/src/cmd/compile/internal/syntax/scanner_test.go +++ b/src/cmd/compile/internal/syntax/scanner_test.go @@ -652,3 +652,25 @@ func TestIssue21938(t *testing.T) { t.Errorf("got %s %q; want %s %q", got.tok, got.lit, _Literal, ".5") } } + +func TestIssue33961(t *testing.T) { + literals := `08__ 0b.p 0b_._p 0x.e 0x.p` + for _, lit := range strings.Split(literals, " ") { + n := 0 + var got scanner + got.init(strings.NewReader(lit), func(_, _ uint, msg string) { + // fmt.Printf("%s: %s\n", lit, msg) // uncomment for debugging + n++ + }, 0) + got.next() + + if n != 1 { + t.Errorf("%q: got %d errors; want 1", lit, n) + continue + } + + if !got.bad { + t.Errorf("%q: got error but bad not set", lit) + } + } +} |