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
This commit is contained in:
Christopher Chedeau authored and GitHub committed 2017-01-22 12:34:27 -08:00
1 parent 58a97ab597
commit 1f92218a06
4 files changed
+18

No files matched your search

+7
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"),
":",
@@ -0,0 +1,8 @@
exports[`test empty_label.js 1`] = `
"a:;
b
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a:;
b;
"
`;
+2
View File
@@ -0,0 +1,2 @@
a:;
b
+1
View File
@@ -0,0 +1 @@
run_spec(__dirname);