diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-12-27 05:32:18 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-27 13:32:18 +0800 |
commit | a8785fb6943e9cf8e370e19f29945e544b3be4b2 (patch) | |
tree | f3bd80c716943b98345ba885c6c34795b61ac6cd /lib/scope.js | |
parent | dd6d7b3d88072bebdd21fedc10abd6e04ff7d094 (diff) | |
download | tracifyjs-a8785fb6943e9cf8e370e19f29945e544b3be4b2.tar.gz tracifyjs-a8785fb6943e9cf8e370e19f29945e544b3be4b2.zip |
workaround v8 bug with labels (#4467)
closes #4466
Diffstat (limited to 'lib/scope.js')
-rw-r--r-- | lib/scope.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/scope.js b/lib/scope.js index c59dc0a7..0c35b0dd 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -512,6 +512,7 @@ function _default_mangler_options(options) { keep_fnames : false, reserved : [], toplevel : false, + v8 : false, webkit : false, }); if (!Array.isArray(options.reserved)) options.reserved = []; @@ -543,7 +544,7 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) { // lname is incremented when we get to the AST_Label var save_nesting = lname; descend(); - lname = save_nesting; + if (!options.v8 || !in_label(tw)) lname = save_nesting; return true; } if (node instanceof AST_BlockScope) { @@ -616,6 +617,14 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) { sym.thedef = def; } } + + function in_label(tw) { + var level = 0, parent; + while (parent = tw.parent(level++)) { + if (parent instanceof AST_Block) return parent instanceof AST_Toplevel && !options.toplevel; + if (parent instanceof AST_LabeledStatement) return true; + } + } }); AST_Toplevel.DEFMETHOD("find_colliding_names", function(options) { |