https://bugs.llvm.org/show_bug.cgi?id=49960
Bug ID: 49960
Summary: clang-format doesn't handle ASI after "return" on
JavaScript
Product: clang
Version: 11.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Formatter
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected]
Sample code:
```
function t() {
if (true) return
const v = 42
}
```
clang-format result:
```
function t() {
if (true)
return const v = 42
}
```
which is incorrect in grammar.
According to ECMA262 12.9.1 [1], a semicolon should be automatically inserted
after "return" for the code sample (also, there's is an example in 12.9.2 like
this). After manually inserting a semicolon after "return", the clang-format
returns the correct formatting result.
1. https://tc39.es/ecma262/#sec-rules-of-automatic-semicolon-insertion
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs