aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-04-26 05:10:22 +0800
committerGitHub <noreply@github.com>2021-04-26 05:10:22 +0800
commitacf951a5bc9d79dc2614d880758e3e7f79f975ae (patch)
tree1793e177344c8fea7e9bb2539c13cd2c074fcaf0
parent324587f76980114e030c59165a60bd285ca05be0 (diff)
downloadtracifyjs-acf951a5bc9d79dc2614d880758e3e7f79f975ae.tar.gz
tracifyjs-acf951a5bc9d79dc2614d880758e3e7f79f975ae.zip
fix corner case with `for [await]...of` (#4872)
-rw-r--r--lib/parse.js1
-rw-r--r--test/compress/loops.js14
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/parse.js b/lib/parse.js
index 415a20ee..dd8e70e9 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -1240,6 +1240,7 @@ function parse($TEXT, options) {
}
function for_enum(ctor, init) {
+ handle_regexp();
var obj = expression();
expect(")");
return new ctor({
diff --git a/test/compress/loops.js b/test/compress/loops.js
index 4ba0d075..c1f075cc 100644
--- a/test/compress/loops.js
+++ b/test/compress/loops.js
@@ -852,6 +852,20 @@ for_async_of: {
node_version: ">=0.12 <16"
}
+for_of_regexp: {
+ input: {
+ for (var a of /foo/);
+ }
+ expect_exact: "for(var a of/foo/);"
+}
+
+for_await_of_regexp: {
+ input: {
+ for await (var a of /foo/);
+ }
+ expect_exact: "for await(var a of/foo/);"
+}
+
issue_3631_1: {
options = {
dead_code: true,