fix(es/codegen): Support multiline comments in return stmt (#4102)

This commit is contained in:
Austaras 2022-03-20 15:11:23 +08:00 committed by GitHub
parent 06c1b3ecb5
commit 552f16dba6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 1 deletions

View File

@ -0,0 +1,7 @@
function test() {
return (
/* my multiline
comment */
0
);
}

View File

@ -0,0 +1,4 @@
function test() {
return(/* my multiline
comment */ 0);
}

View File

@ -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;
}
}