From 0292ad33eb209e5bb23f4d4a552489dbc8ada203 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Fri, 2 Jul 2021 14:46:58 +0430 Subject: LibJS: Make a slash after a curly close mean not-division There's no grammar rule that allows this. --- Userland/Libraries/LibJS/Lexer.cpp | 1 - Userland/Libraries/LibJS/Tests/syntax/slash-after-block.js | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 Userland/Libraries/LibJS/Tests/syntax/slash-after-block.js (limited to 'Userland/Libraries') diff --git a/Userland/Libraries/LibJS/Lexer.cpp b/Userland/Libraries/LibJS/Lexer.cpp index 5d39c5431e..0263231065 100644 --- a/Userland/Libraries/LibJS/Lexer.cpp +++ b/Userland/Libraries/LibJS/Lexer.cpp @@ -360,7 +360,6 @@ bool Lexer::slash_means_division() const return type == TokenType::BigIntLiteral || type == TokenType::BoolLiteral || type == TokenType::BracketClose - || type == TokenType::CurlyClose || type == TokenType::Identifier || type == TokenType::NullLiteral || type == TokenType::NumericLiteral diff --git a/Userland/Libraries/LibJS/Tests/syntax/slash-after-block.js b/Userland/Libraries/LibJS/Tests/syntax/slash-after-block.js new file mode 100644 index 0000000000..67839147f9 --- /dev/null +++ b/Userland/Libraries/LibJS/Tests/syntax/slash-after-block.js @@ -0,0 +1,6 @@ +test("slash token resolution in lexer", () => { + expect(`{ blah.blah; }\n/foo/`).toEval(); + expect("``/foo/").not.toEval(); + expect("1/foo/").not.toEval(); + expect("1/foo").toEval(); +}); -- cgit v1.2.3