diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-12-19 12:28:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-19 12:28:38 +0800 |
commit | e6dd471f8fff84c878153008139150a090c5ba19 (patch) | |
tree | ec207ca4b7416a79b9abba17fdda35b44e5ef743 /lib/ast.js | |
parent | 0f55bd92f18bd27628f1cfd10c9fb5d70f4d4d29 (diff) | |
download | tracifyjs-e6dd471f8fff84c878153008139150a090c5ba19.tar.gz tracifyjs-e6dd471f8fff84c878153008139150a090c5ba19.zip |
support destructuring of `catch` variable (#4412)
Diffstat (limited to 'lib/ast.js')
-rw-r--r-- | lib/ast.js | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -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) { |