aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/syntax/scanner_test.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2017-09-19 14:28:03 -0700
committerMatthew Dempsky <mdempsky@google.com>2017-09-20 17:47:26 +0000
commite06a64a4768445f2fcea1cb6b5a04abe0c4d9d12 (patch)
treebde00cb4598ea2b5cd52c78e5b3f8ad837d3176e /src/cmd/compile/internal/syntax/scanner_test.go
parenta53e853964cc9220ebc4b35aeb81a382939fb479 (diff)
downloadgo-e06a64a4768445f2fcea1cb6b5a04abe0c4d9d12.tar.gz
go-e06a64a4768445f2fcea1cb6b5a04abe0c4d9d12.zip
cmd/compile/internal/syntax: fix source buffer refilling
The previous code seems to have an off-by-1 in it somewhere, the consequence being that we didn't properly preserve all of the old buffer contents that we intended to. After spending a while looking at the existing window-shifting logic, I wasn't able to understand exactly how it was supposed to work or where the issue was, so I rewrote it to be (at least IMO) more obviously correct. Fixes #21938. Change-Id: I1ed7bbc1e1751a52ab5f7cf0411ae289586dc345 Reviewed-on: https://go-review.googlesource.com/64830 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/syntax/scanner_test.go')
-rw-r--r--src/cmd/compile/internal/syntax/scanner_test.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/syntax/scanner_test.go b/src/cmd/compile/internal/syntax/scanner_test.go
index e434db9a91..53995e0c79 100644
--- a/src/cmd/compile/internal/syntax/scanner_test.go
+++ b/src/cmd/compile/internal/syntax/scanner_test.go
@@ -7,6 +7,7 @@ package syntax
import (
"fmt"
"os"
+ "strings"
"testing"
)
@@ -367,3 +368,15 @@ func TestScanErrors(t *testing.T) {
}
}
}
+
+func TestIssue21938(t *testing.T) {
+ s := "/*" + strings.Repeat(" ", 4089) + "*/ .5"
+
+ var got scanner
+ got.init(strings.NewReader(s), nil, nil)
+ got.next()
+
+ if got.tok != _Literal || got.lit != ".5" {
+ t.Errorf("got %s %q; want %s %q", got.tok, got.lit, _Literal, ".5")
+ }
+}