support destructuring of catch variable (#4412)
This commit is contained in:
10
lib/ast.js
10
lib/ast.js
@@ -786,7 +786,7 @@ var AST_Try = DEFNODE("Try", "bcatch bfinally", {
|
||||
var AST_Catch = DEFNODE("Catch", "argname", {
|
||||
$documentation: "A `catch` node; only makes sense as part of a `try` statement",
|
||||
$propdoc: {
|
||||
argname: "[AST_SymbolCatch?] symbol for the exception, or null if not present",
|
||||
argname: "[(AST_Destructured|AST_SymbolCatch)?] symbol for the exception, or null if not present",
|
||||
},
|
||||
walk: function(visitor) {
|
||||
var node = this;
|
||||
@@ -796,9 +796,9 @@ var AST_Catch = DEFNODE("Catch", "argname", {
|
||||
});
|
||||
},
|
||||
_validate: function() {
|
||||
if (this.argname != null) {
|
||||
if (!(this.argname instanceof AST_SymbolCatch)) throw new Error("argname must be AST_SymbolCatch");
|
||||
}
|
||||
if (this.argname != null) validate_destructured(this.argname, function(node) {
|
||||
if (!(node instanceof AST_SymbolCatch)) throw new Error("argname must be AST_SymbolCatch");
|
||||
});
|
||||
},
|
||||
}, AST_Block);
|
||||
|
||||
@@ -868,7 +868,7 @@ var AST_Var = DEFNODE("Var", null, {
|
||||
var AST_VarDef = DEFNODE("VarDef", "name value", {
|
||||
$documentation: "A variable declaration; only appears in a AST_Definitions node",
|
||||
$propdoc: {
|
||||
name: "[AST_SymbolVar] name of the variable",
|
||||
name: "[AST_Destructured|AST_SymbolVar] name of the variable",
|
||||
value: "[AST_Node?] initializer, or null of there's no initializer"
|
||||
},
|
||||
walk: function(visitor) {
|
||||
|
||||
Reference in New Issue
Block a user