Fix empty labels (#383)
We actually need this `;` for EmptyStatement, otherwise it applies to the next block of code. (Creating a label with an empty statement is completely useless, but it triggers a lot in the fuzz testing tool) Fixes #376master
parent
58a97ab597
commit
1f92218a06
|
@ -921,6 +921,13 @@ function genericPrintNoParens(path, options, print) {
|
|||
|
||||
return concat(parts);
|
||||
case "LabeledStatement":
|
||||
if (n.body.type === "EmptyStatement") {
|
||||
return concat([
|
||||
path.call(print, "label"),
|
||||
":;"
|
||||
]);
|
||||
}
|
||||
|
||||
return concat([
|
||||
path.call(print, "label"),
|
||||
":",
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
exports[`test empty_label.js 1`] = `
|
||||
"a:;
|
||||
b
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
a:;
|
||||
b;
|
||||
"
|
||||
`;
|
|
@ -0,0 +1,2 @@
|
|||
a:;
|
||||
b
|
|
@ -0,0 +1 @@
|
|||
run_spec(__dirname);
|
Loading…
Reference in New Issue