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 #376
master
Christopher Chedeau 2017-01-22 12:34:27 -08:00 committed by GitHub
parent 58a97ab597
commit 1f92218a06
4 changed files with 18 additions and 0 deletions

View File

@ -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"),
":",

View File

@ -0,0 +1,8 @@
exports[`test empty_label.js 1`] = `
"a:;
b
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a:;
b;
"
`;

View File

@ -0,0 +1,2 @@
a:;
b

View File

@ -0,0 +1 @@
run_spec(__dirname);