fix corner case in webkit (#5483)

fixes #5480
This commit is contained in:
Alex Lam S.L
2022-06-01 19:45:02 +01:00
committed by GitHub
parent 40e669eacb
commit ad5f5ef2a3
5 changed files with 210 additions and 197 deletions

View File

@@ -622,14 +622,10 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
var lname = -1;
var redefined = [];
var tw = new TreeWalker(function(node, descend) {
if (node instanceof AST_LabeledStatement) {
// `lname` is incremented when we get to the `AST_Label`
var save_nesting = lname;
descend();
if (!options.v8 || !in_label(tw)) lname = save_nesting;
return true;
}
var save_nesting;
if (node instanceof AST_BlockScope) {
// `lname` is incremented when we get to the `AST_Label`
if (node instanceof AST_LabeledStatement) save_nesting = lname;
if (options.webkit && node instanceof AST_IterationStatement && node.init instanceof AST_Let) {
node.init.definitions.forEach(function(defn) {
defn.name.match_symbol(function(sym) {
@@ -675,6 +671,7 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
}));
}
to_mangle.forEach(mangle);
if (node instanceof AST_LabeledStatement && !(options.v8 && in_label(tw))) lname = save_nesting;
return true;
}
if (node instanceof AST_Label) {