Fix scanning of float with leading zero (#486)

This commit is contained in:
Cameron Moore
2021-03-29 19:07:26 -05:00
committed by GitHub
parent 6165b9454f
commit 7d8ea80dc3
2 changed files with 16 additions and 1 deletions
+1 -1
View File
@@ -1056,7 +1056,7 @@ func (p *parser) parseTime(b []byte) ([]byte, error) {
func (p *parser) scanIntOrFloat(b []byte) (ast.Reference, []byte, error) {
i := 0
if len(b) > 2 && b[0] == '0' {
if len(b) > 2 && b[0] == '0' && b[1] != '.' {
var isValidRune validRuneFn
switch b[1] {
case 'x':
+15
View File
@@ -49,6 +49,21 @@ func TestParser_AST_Numbers(t *testing.T) {
input: `0b11010110`,
kind: ast.Integer,
},
{
desc: "float zero",
input: `0.0`,
kind: ast.Float,
},
{
desc: "float positive zero",
input: `+0.0`,
kind: ast.Float,
},
{
desc: "float negative zero",
input: `-0.0`,
kind: ast.Float,
},
{
desc: "float pi",
input: `3.1415`,