Skip discriminant when renaming starting from SwitchStatement (#12530)
This commit is contained in:
parent
814212f0be
commit
e08f68bf61
@ -0,0 +1,20 @@
|
|||||||
|
window.test = () => {
|
||||||
|
const e = "TEST";
|
||||||
|
switch (e) {
|
||||||
|
case "TEST":
|
||||||
|
const e = [];
|
||||||
|
e.push('111');
|
||||||
|
alert(e);
|
||||||
|
break;
|
||||||
|
default: alert('666'); break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.test = () => {
|
||||||
|
const e = "TEST";
|
||||||
|
switch (e) {
|
||||||
|
case "TEST":
|
||||||
|
const e = [];
|
||||||
|
switch(e) {}
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
window.test = function () {
|
||||||
|
var e = "TEST";
|
||||||
|
|
||||||
|
switch (e) {
|
||||||
|
case "TEST":
|
||||||
|
var _e = [];
|
||||||
|
|
||||||
|
_e.push('111');
|
||||||
|
|
||||||
|
alert(_e);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
alert('666');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.test = function () {
|
||||||
|
var e = "TEST";
|
||||||
|
|
||||||
|
switch (e) {
|
||||||
|
case "TEST":
|
||||||
|
var _e2 = [];
|
||||||
|
|
||||||
|
switch (_e2) {}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -119,7 +119,15 @@ export default class Renamer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.traverse(block || scope.block, renameVisitor, this);
|
const blockToTraverse = block || scope.block;
|
||||||
|
if (blockToTraverse?.type === "SwitchStatement") {
|
||||||
|
// discriminant is not part of current scope, should be skipped.
|
||||||
|
blockToTraverse.cases.forEach(c => {
|
||||||
|
scope.traverse(c, renameVisitor, this);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
scope.traverse(blockToTraverse, renameVisitor, this);
|
||||||
|
}
|
||||||
|
|
||||||
if (!block) {
|
if (!block) {
|
||||||
scope.removeOwnBinding(oldName);
|
scope.removeOwnBinding(oldName);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user