1
0
mirror of https://github.com/golang/go synced 2024-11-22 03:44:39 -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:
Evan Shaw 2010-04-15 19:53:35 -07:00 committed by Robert Griesemer
parent ff922fe15a
commit 9ca10b0a5c
2 changed files with 2 additions and 1 deletions

View File

@ -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)
}

View File

@ -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)),