diff options
author | Ayke van Laethem <[email protected]> | 2019-12-30 21:52:36 +0100 |
---|---|---|
committer | Ron Evans <[email protected]> | 2020-01-03 23:44:58 +0100 |
commit | b424056721de48b883ba8172e989386c5d471abc (patch) | |
tree | c7849b06fc93778dd2e999b2137ef95560cae8e8 /cgo | |
parent | d735df6e169a0513ecf43323a2e2e628d9d95a85 (diff) | |
download | tinygo-b424056721de48b883ba8172e989386c5d471abc.tar.gz tinygo-b424056721de48b883ba8172e989386c5d471abc.zip |
cgo: fix a bug in number tokenization
Diffstat (limited to 'cgo')
-rw-r--r-- | cgo/const.go | 4 | ||||
-rw-r--r-- | cgo/const_test.go | 1 |
2 files changed, 4 insertions, 1 deletions
diff --git a/cgo/const.go b/cgo/const.go index f69bbb817..c2451bc0b 100644 --- a/cgo/const.go +++ b/cgo/const.go @@ -140,8 +140,10 @@ func (t *tokenizer) Next() { if c == '.' { hasDot = true } - if (c >= '0' && c <= '9') || c == '.' || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') { + if c >= '0' && c <= '9' || c == '.' || c == '_' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' { tokenLen = i + 1 + } else { + break } } t.value = t.buf[:tokenLen] diff --git a/cgo/const_test.go b/cgo/const_test.go index eaac3047f..cfba45079 100644 --- a/cgo/const_test.go +++ b/cgo/const_test.go @@ -30,6 +30,7 @@ func TestParseConst(t *testing.T) { {`'a'`, `'a'`}, {`0b10`, `0b10`}, {`0x1234_5678`, `0x1234_5678`}, + {`5 5`, `error: 1:3: unexpected token INT`}, // test for a bugfix } { fset := token.NewFileSet() startPos := fset.AddFile("", -1, 1000).Pos(0) |