mirror of https://github.com/golang/go.git
go/scanner: don't allow "0x" and "0X" as integers
R=gri CC=golang-dev https://golang.org/cl/4560047
This commit is contained in:
parent
399a311e64
commit
f369fc09f4
|
|
@ -297,6 +297,10 @@ func (S *Scanner) scanNumber(seenDecimalPoint bool) token.Token {
|
|||
// hexadecimal int
|
||||
S.next()
|
||||
S.scanMantissa(16)
|
||||
if S.offset-offs <= 2 {
|
||||
// only scanned "0x" or "0X"
|
||||
S.error(offs, "illegal hexadecimal number")
|
||||
}
|
||||
} else {
|
||||
// octal int or float
|
||||
seenDecimalDigit := false
|
||||
|
|
|
|||
|
|
@ -672,6 +672,8 @@ var errors = []struct {
|
|||
{"078e0", token.FLOAT, 0, ""},
|
||||
{"078", token.INT, 0, "illegal octal number"},
|
||||
{"07800000009", token.INT, 0, "illegal octal number"},
|
||||
{"0x", token.INT, 0, "illegal hexadecimal number"},
|
||||
{"0X", token.INT, 0, "illegal hexadecimal number"},
|
||||
{"\"abc\x00def\"", token.STRING, 4, "illegal character NUL"},
|
||||
{"\"abc\x80def\"", token.STRING, 4, "illegal UTF-8 encoding"},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue