From 9217dda7b2c6f0fcb927e977c9396ce316fda89f Mon Sep 17 00:00:00 2001 From: Anton Medvedev Date: Mon, 2 Mar 2020 13:47:15 +0300 Subject: [PATCH] Fix exponent parse error --- parser/parser.go | 2 +- parser/parser_test.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/parser/parser.go b/parser/parser.go index cb31f7049..a97ec8ddc 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -282,7 +282,7 @@ func (p *parser) parsePrimaryExpression() Node { case Number: p.next() value := strings.Replace(token.Value, "_", "", -1) - if strings.Contains(value, ".") { + if strings.ContainsAny(value, ".eE") { number, err := strconv.ParseFloat(value, 64) if err != nil { p.error("invalid float literal: %v", err) diff --git a/parser/parser_test.go b/parser/parser_test.go index 964d7c3cf..5b37ad7b1 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -39,6 +39,10 @@ func TestParse(t *testing.T) { "2.5", &ast.FloatNode{Value: 2.5}, }, + { + "1e9", + &ast.FloatNode{Value: 1e9}, + }, { "true", &ast.BoolNode{Value: true},