aboutsummaryrefslogtreecommitdiff
path: root/lib/ast.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-12-19 12:28:38 +0800
committerGitHub <noreply@github.com>2020-12-19 12:28:38 +0800
commite6dd471f8fff84c878153008139150a090c5ba19 (patch)
treeec207ca4b7416a79b9abba17fdda35b44e5ef743 /lib/ast.js
parent0f55bd92f18bd27628f1cfd10c9fb5d70f4d4d29 (diff)
downloadtracifyjs-e6dd471f8fff84c878153008139150a090c5ba19.tar.gz
tracifyjs-e6dd471f8fff84c878153008139150a090c5ba19.zip
support destructuring of `catch` variable (#4412)
Diffstat (limited to 'lib/ast.js')
-rw-r--r--lib/ast.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/ast.js b/lib/ast.js
index fcbfb710..e966cefa 100644
--- a/lib/ast.js
+++ b/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) {