mirror of
https://github.com/swc-project/swc.git
synced 2024-12-24 14:16:12 +03:00
fix(es/codegen): Support multiline comments in return stmt (#4102)
This commit is contained in:
parent
06c1b3ecb5
commit
552f16dba6
7
crates/swc/tests/fixture/issue-4098/input/index.js
Normal file
7
crates/swc/tests/fixture/issue-4098/input/index.js
Normal file
@ -0,0 +1,7 @@
|
||||
function test() {
|
||||
return (
|
||||
/* my multiline
|
||||
comment */
|
||||
0
|
||||
);
|
||||
}
|
4
crates/swc/tests/fixture/issue-4098/output/index.js
Normal file
4
crates/swc/tests/fixture/issue-4098/output/index.js
Normal file
@ -0,0 +1,4 @@
|
||||
function test() {
|
||||
return(/* my multiline
|
||||
comment */ 0);
|
||||
}
|
@ -2538,7 +2538,14 @@ where
|
||||
|
||||
// see #415
|
||||
if let Some(cmt) = cmt.get_leading(lo) {
|
||||
if cmt.iter().any(|cmt| cmt.kind == CommentKind::Line) {
|
||||
if cmt.iter().any(|cmt| {
|
||||
cmt.kind == CommentKind::Line
|
||||
|| cmt
|
||||
.text
|
||||
.chars()
|
||||
// https://tc39.es/ecma262/#table-line-terminator-code-points
|
||||
.any(|c| c == '\n' || c == '\r' || c == '\u{2028}' || c == '\u{2029}')
|
||||
}) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user