parse parentheses-terminated statements correctly (#4774)
authorAlex Lam S.L <alexlamsl@gmail.com>
Sun, 14 Mar 2021 06:09:29 +0000 (06:09 +0000)
committerGitHub <noreply@github.com>
Sun, 14 Mar 2021 06:09:29 +0000 (14:09 +0800)
fixes #4772

lib/parse.js
test/compress/arrows.js

index 21f76f5..7bea41d 100644 (file)
@@ -1835,7 +1835,10 @@ function parse($TEXT, options) {
                 expect(")");
                 var end = prev();
                 end.comments_before = ex.end.comments_before;
-                [].push.apply(ex.end.comments_after, end.comments_after);
+                end.comments_after.forEach(function(comment) {
+                    ex.end.comments_after.push(comment);
+                    if (comment.nlb) S.token.nlb = true;
+                });
                 end.comments_after.length = 0;
                 end.comments_after = ex.end.comments_after;
                 ex.end = end;
index 6cb5522..c906aa4 100644 (file)
@@ -803,3 +803,13 @@ issue_4687_2: {
     expect_stdout: "PASS"
     node_version: ">=4"
 }
+
+issue_4772: {
+    input: {
+        var f = a => (a)
+        /**/ console.log(f("PASS"));
+    }
+    expect_exact: 'var f=a=>a;console.log(f("PASS"));'
+    expect_stdout: "PASS"
+    node_version: ">=4"
+}