[llvm-bugs] [Bug 49960] New: clang-format doesn't handle ASI after "return" on JavaScript
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Apr 14 00:29:28 PDT 2021
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: unassignedclangbugs at nondot.org
Reporter: i at outv.im
CC: djasper at google.com, klimek at google.com,
llvm-bugs at lists.llvm.org
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210414/e0a06bd0/attachment.html>
More information about the llvm-bugs
mailing list