Commit 9ca10b0a authored by Evan Shaw's avatar Evan Shaw Committed by Robert Griesemer

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
parent ff922fe1
......@@ -762,7 +762,7 @@ func (a *exprInfo) compileCharLit(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) {
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.0", bignum.Rat(1, 1)),
Val("01.5", bignum.Rat(15, 10)),
CErr("+\"x\"", opTypes),
Val("-42", bignum.Int(-42)),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment