aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-03-14 06:09:29 +0000
committerGitHub <noreply@github.com>2021-03-14 14:09:29 +0800
commite124ef57e34190205534aa3ab856a7fcb6caaab5 (patch)
treeea9d8cf90b0b630de3270b4d4c35bb7c4e0e0158
parent73e6b2550bf0cc08e4bc95ac1e1d3b8b650c5bf8 (diff)
downloadtracifyjs-e124ef57e34190205534aa3ab856a7fcb6caaab5.tar.gz
tracifyjs-e124ef57e34190205534aa3ab856a7fcb6caaab5.zip
parse parentheses-terminated statements correctly (#4774)
fixes #4772
-rw-r--r--lib/parse.js5
-rw-r--r--test/compress/arrows.js10
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/parse.js b/lib/parse.js
index 21f76f5b..7bea41d8 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -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;
diff --git a/test/compress/arrows.js b/test/compress/arrows.js
index 6cb55223..c906aa4c 100644
--- a/test/compress/arrows.js
+++ b/test/compress/arrows.js
@@ -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"
+}