aboutsummaryrefslogtreecommitdiff
path: root/lib/scope.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-10-04 22:30:14 +0100
committerGitHub <noreply@github.com>2020-10-05 05:30:14 +0800
commit8f0521d51d0292cc84782628cda1a9d16b083ed6 (patch)
treeadd858505f6b35a72f76f0a19c5d36f222432725 /lib/scope.js
parentf9946767c9e517561253eed22558fb154daf84d1 (diff)
downloadtracifyjs-8f0521d51d0292cc84782628cda1a9d16b083ed6.tar.gz
tracifyjs-8f0521d51d0292cc84782628cda1a9d16b083ed6.zip
retrofit `try-catch-finally` as block-scoped (#4178)
- support optional catch binding
Diffstat (limited to 'lib/scope.js')
-rw-r--r--lib/scope.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/scope.js b/lib/scope.js
index 359bd883..86fd3957 100644
--- a/lib/scope.js
+++ b/lib/scope.js
@@ -114,6 +114,14 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
});
return true;
}
+ if (node instanceof AST_Try) {
+ walk_scope(function() {
+ walk_body(node, tw);
+ });
+ if (node.bcatch) node.bcatch.walk(tw);
+ if (node.bfinally) node.bfinally.walk(tw);
+ return true;
+ }
if (node instanceof AST_BlockScope) {
walk_scope(descend);
return true;
@@ -468,7 +476,7 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
node.mangled_name = name;
return true;
}
- if (!options.ie8 && node instanceof AST_Catch) {
+ if (!options.ie8 && node instanceof AST_Catch && node.argname) {
var def = node.argname.definition();
var redef = defer_redef(def, node.argname);
descend();