Handle esprima-like AST catch clause in a TryStatement. Fixes #473

This commit is contained in:
Amjad Masad 2015-01-12 17:32:02 -05:00
parent 7b04c501eb
commit e07e74f010

View File

@ -107,7 +107,16 @@ exports.TryStatement = function (node, print) {
this.keyword("try");
print(node.block);
this.space();
print(node.handler);
// Esprima bug puts the catch clause in a `handlers` array.
// see https://code.google.com/p/esprima/issues/detail?id=433
// We run into this from regenerator generated ast.
if (node.handlers) {
print(node.handlers[0]);
} else {
print(node.handler);
}
if (node.finalizer) {
this.space();
this.push("finally ");