fix corner case with template literals (#4631)
authorAlex Lam S.L <alexlamsl@gmail.com>
Tue, 9 Feb 2021 06:21:15 +0000 (06:21 +0000)
committerGitHub <noreply@github.com>
Tue, 9 Feb 2021 06:21:15 +0000 (14:21 +0800)
fixes #4630

lib/parse.js
test/compress/templates.js

index c8f63d8..b926f18 100644 (file)
@@ -249,6 +249,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
                     if (peek() == "{") {
                         next();
                         strings.push(s);
+                        S.regex_allowed = true;
                         return true;
                     }
                 }
index 0be46df..8ea4d39 100644 (file)
@@ -283,3 +283,18 @@ issue_4606: {
     expect_stdout: "undefined \r \\ `"
     node_version: ">=4"
 }
+
+issue_4630: {
+    options = {
+        evaluate: true,
+        templates: true,
+    }
+    input: {
+        console.log(`${/PASS/}`);
+    }
+    expect: {
+        console.log("/PASS/");
+    }
+    expect_stdout: "/PASS/"
+    node_version: ">=4"
+}