Revert "fix up types.toStatement and return an expressionStatement if all else fails"

This reverts commit 740193b1e2.
This commit is contained in:
Sebastian McKenzie
2014-11-14 09:28:04 +11:00
parent 38396dadd5
commit 297e55ba63

View File

@@ -119,12 +119,18 @@ t.toStatement = function (node, ignore) {
} else if (t.isFunction(node)) {
mustHaveId = true;
newType = "FunctionDeclaration";
} else {
return t.expressionStatement(node);
}
if (mustHaveId && !node.id) {
throw new Error("the type " + node.type + " needs an id in order to be transformed into a statement");
newType = false;
}
if (!newType) {
if (ignore) {
return false;
} else {
throw new Error("cannot turn " + node.type + " to a statement");
}
}
node.type = newType;