From acf951a5bc9d79dc2614d880758e3e7f79f975ae Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Mon, 26 Apr 2021 05:10:22 +0800 Subject: [PATCH] fix corner case with `for [await]...of` (#4872) --- lib/parse.js | 1 + test/compress/loops.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/parse.js b/lib/parse.js index 415a20ee6b..dd8e70e93f 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 4ba0d075d9..c1f075cc16 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,