1
0
mirror of https://github.com/golang/go synced 2024-09-30 13:28:38 -06:00

go/scanner: recognize invalid floating-point constant exponent

Fixes #17621.

Change-Id: Id3e75c9b7fba2cf8e791c8817f890556ca238e9d
Reviewed-on: https://go-review.googlesource.com/32096
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
Robert Griesemer 2016-10-26 15:52:56 -07:00
parent 4b2665786e
commit 3cfc757c62
2 changed files with 6 additions and 1 deletions

View File

@ -349,7 +349,11 @@ exponent:
if s.ch == '-' || s.ch == '+' {
s.next()
}
if digitVal(s.ch) < 10 {
s.scanMantissa(10)
} else {
s.error(offs, "illegal floating-point exponent")
}
}
if s.ch == 'i' {

View File

@ -717,6 +717,7 @@ var errors = []struct {
{"078.", token.FLOAT, 0, "078.", ""},
{"07801234567.", token.FLOAT, 0, "07801234567.", ""},
{"078e0", token.FLOAT, 0, "078e0", ""},
{"0E", token.FLOAT, 0, "0E", "illegal floating-point exponent"}, // issue 17621
{"078", token.INT, 0, "078", "illegal octal number"},
{"07800000009", token.INT, 0, "07800000009", "illegal octal number"},
{"0x", token.INT, 0, "0x", "illegal hexadecimal number"},