Fix scanning of float with leading zero (#486)
This commit is contained in:
@@ -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':
|
||||
|
||||
@@ -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`,
|
||||
|
||||
Reference in New Issue
Block a user