improve handling of switch statements (#4114)

This commit is contained in:
Alex Lam S.L
2020-09-16 20:12:08 +01:00
committed by GitHub
parent 2a053710bd
commit a9d934ab4e
3 changed files with 37 additions and 37 deletions

View File

@@ -631,6 +631,9 @@ var AST_Switch = DEFNODE("Switch", "expression", {
},
_validate: function() {
must_be_expression(this, "expression");
this.body.forEach(function(node) {
if (!(node instanceof AST_SwitchBranch)) throw new Error("body must be AST_SwitchBranch[]");
});
},
}, AST_Block);