From eb364f03015b768b5ae2c0318f4f2fa1838d4c29 Mon Sep 17 00:00:00 2001 From: Larpon Date: Fri, 22 Oct 2021 18:56:43 +0200 Subject: [PATCH] toml: check for exponents starting with an underscore (#12271) --- vlib/toml/checker/checker.v | 4 ++++ vlib/toml/tests/burntsushi.toml-test_test.v | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/vlib/toml/checker/checker.v b/vlib/toml/checker/checker.v index 5d1648b49a..412d606663 100644 --- a/vlib/toml/checker/checker.v +++ b/vlib/toml/checker/checker.v @@ -160,6 +160,10 @@ fn (c Checker) check_number(num ast.Number) ? { } if has_exponent_notation { + if lit.to_lower().all_after('e').starts_with('_') { + return error(@MOD + '.' + @STRUCT + '.' + @FN + + ' the exponent in "$lit" can not start with an underscore in ...${c.excerpt(num.pos)}...') + } if lit.to_lower().all_after('e').contains('.') { return error(@MOD + '.' + @STRUCT + '.' + @FN + ' numbers like "$lit" (with exponent) can not have a decimal point in ...${c.excerpt(num.pos)}...') diff --git a/vlib/toml/tests/burntsushi.toml-test_test.v b/vlib/toml/tests/burntsushi.toml-test_test.v index e48849caee..9423cbdb6a 100644 --- a/vlib/toml/tests/burntsushi.toml-test_test.v +++ b/vlib/toml/tests/burntsushi.toml-test_test.v @@ -22,8 +22,6 @@ const ( // Encoding 'encoding/bad-utf8-in-comment.toml', 'encoding/bad-utf8-in-string.toml', - // Float - 'float/exp-leading-us.toml', // Table 'table/rrbrace.toml', 'table/duplicate-table-array2.toml',