Fix path.scope.rename() to not change break clauses (#8478)

* Make labels on break and continue statements not referenced

* Add test for imports and labels with the same name
This commit is contained in:
Rafael de Oleza 2018-08-23 14:20:57 -07:00 committed by Logan Smyth
parent 47e05d70f3
commit 22bcfbe469
7 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,5 @@
import foo from "foo";
foo: {
break foo;
}

View File

@ -0,0 +1,5 @@
import foo from "foo";
foo: {
break foo;
}

View File

@ -0,0 +1,9 @@
function f(a) {
a: for (const k in []) {
if (k) {
continue a;
} else {
break a;
}
}
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["./plugin"]
}

View File

@ -0,0 +1,9 @@
function f(b) {
a: for (const k in []) {
if (k) {
continue a;
} else {
break a;
}
}
}

View File

@ -0,0 +1,9 @@
module.exports = function() {
return {
visitor: {
Function(path) {
path.scope.rename("a", "b");
}
}
};
}

View File

@ -80,6 +80,10 @@ export default function isReferenced(node: Object, parent: Object): boolean {
case "RestElement":
return false;
case "BreakStatement":
case "ContinueStatement":
return false;
// no: function NODE() {}
// no: function foo(NODE) {}
case "FunctionDeclaration":