mirror of
https://github.com/golang/go
synced 2024-11-25 07:07:57 -07:00
exp/eval: Always read float literals as base 10
We were letting bignum decide, which caused problems with float literals with a leading 0. R=gri CC=golang-dev https://golang.org/cl/816047
This commit is contained in:
parent
ff922fe15a
commit
9ca10b0a5c
@ -762,7 +762,7 @@ func (a *exprInfo) compileCharLit(lit string) *expr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *exprInfo) compileFloatLit(lit string) *expr {
|
func (a *exprInfo) compileFloatLit(lit string) *expr {
|
||||||
f, _, n := bignum.RatFromString(lit, 0)
|
f, _, n := bignum.RatFromString(lit, 10)
|
||||||
if n != len(lit) {
|
if n != len(lit) {
|
||||||
log.Crashf("malformed float literal %s at %v passed parser", lit, a.pos)
|
log.Crashf("malformed float literal %s at %v passed parser", lit, a.pos)
|
||||||
}
|
}
|
||||||
|
@ -142,6 +142,7 @@ var exprTests = []test{
|
|||||||
|
|
||||||
Val("+1", bignum.Int(+1)),
|
Val("+1", bignum.Int(+1)),
|
||||||
Val("+1.0", bignum.Rat(1, 1)),
|
Val("+1.0", bignum.Rat(1, 1)),
|
||||||
|
Val("01.5", bignum.Rat(15, 10)),
|
||||||
CErr("+\"x\"", opTypes),
|
CErr("+\"x\"", opTypes),
|
||||||
|
|
||||||
Val("-42", bignum.Int(-42)),
|
Val("-42", bignum.Int(-42)),
|
||||||
|
Loading…
Reference in New Issue
Block a user