浏览代码

LibJS: Make a slash after a curly close mean not-division

There's no grammar rule that allows this.
Ali Mohammad Pur 4 年之前
父节点
当前提交
0292ad33eb
共有 2 个文件被更改,包括 6 次插入1 次删除
  1. 0 1
      Userland/Libraries/LibJS/Lexer.cpp
  2. 6 0
      Userland/Libraries/LibJS/Tests/syntax/slash-after-block.js

+ 0 - 1
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

+ 6 - 0
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();
+});