From d528d165a2838b315a18ad1e8334db32baeb5ad2 Mon Sep 17 00:00:00 2001 From: dlup <93457935+lupd@users.noreply.github.com> Date: Sun, 27 Mar 2022 03:27:56 -0400 Subject: [PATCH] Support numbers with multiple leading zeroes --- boa_engine/src/syntax/lexer/number.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/boa_engine/src/syntax/lexer/number.rs b/boa_engine/src/syntax/lexer/number.rs index 540cf6e2f8a..ef2a08ced5b 100644 --- a/boa_engine/src/syntax/lexer/number.rs +++ b/boa_engine/src/syntax/lexer/number.rs @@ -261,7 +261,7 @@ impl Tokenizer for NumberLiteral { legacy_octal = true; let ch = char::from(byte); if ch.is_digit(8) { - // LegacyOctalIntegerLiteral + // LegacyOctalIntegerLiteral, or a number with leading 0s. if cursor.strict_mode() { // LegacyOctalIntegerLiteral is forbidden with strict mode true. return Err(Error::syntax( @@ -275,7 +275,12 @@ impl Tokenizer for NumberLiteral { buf.push(cursor.next_byte()?.expect("'0' character vanished")); - kind = NumericKind::Integer(8); + take_integer(&mut buf, cursor, NumericKind::Integer(8), false)?; + + if !cursor.next_is_ascii_pred(&|c| c.is_digit(10) || c == '_')? { + // LegacyOctalIntegerLiteral + kind = NumericKind::Integer(8); + } } else if ch.is_digit(10) { // Indicates a numerical digit comes after then 0 but it isn't an octal digit // so therefore this must be a number with an unneeded leading 0. This is