diff --git a/interpres_test.go b/interpres_test.go index 8f80028..f33970a 100644 --- a/interpres_test.go +++ b/interpres_test.go @@ -421,6 +421,10 @@ func TestAcceptsNumberEdgeCases(t *testing.T) { "3.14": 3.14, "6.022e23": 6.022e23, "1e10": 1e10, + "1e0": 1.0, + "1e06": 1e6, + "0e00": 0.0, + "2E-3": 2e-3, "-2.5E-3": -2.5e-3, } for tok, want := range cases { diff --git a/number.go b/number.go index 5da3421..20d1ee3 100644 --- a/number.go +++ b/number.go @@ -104,7 +104,9 @@ func decodeFloat(tok string) (any, error) { build += "." + fp } // The ABNF requires at least one digit after the exponent marker, so a - // trailing e or E is an error even though strconv would accept it. + // trailing e or E is an error even though strconv would accept it. The + // digits are a zero-prefixable integer, so leading zeros are fine here + // (the corpus holds valid cases such as 1e06 and 0e00). if hasExp { esign, edigits := splitSign(exp) ed, err := joinDigits(edigits, isDecDigit)