diff --git a/src/babel/transformation/modules/_default.js b/src/babel/transformation/modules/_default.js index d519d086f3..b038f43ea7 100644 --- a/src/babel/transformation/modules/_default.js +++ b/src/babel/transformation/modules/_default.js @@ -8,7 +8,8 @@ import * as t from "../../types"; var remapVisitor = { enter(node, parent, scope, formatter) { var remap = formatter.internalRemap[node.name]; - if (this.isReferencedIdentifier() && remap) { + + if (this.isReferencedIdentifier() && remap && node !== remap) { if (!scope.hasBinding(node.name) || scope.bindingIdentifierEquals(node.name, formatter.localImports[node.name])) { return remap; } diff --git a/src/babel/transformation/transformers/es6/arrow-functions.js b/src/babel/transformation/transformers/es6/arrow-functions.js index 5c013af522..d40d436727 100644 --- a/src/babel/transformation/transformers/es6/arrow-functions.js +++ b/src/babel/transformation/transformers/es6/arrow-functions.js @@ -8,6 +8,4 @@ export function ArrowFunctionExpression(node) { node.expression = false; node.type = "FunctionExpression"; node.shadow = true; - - return node; } diff --git a/src/babel/transformation/transformers/es6/destructuring.js b/src/babel/transformation/transformers/es6/destructuring.js index 108eda311b..67d1513e65 100644 --- a/src/babel/transformation/transformers/es6/destructuring.js +++ b/src/babel/transformation/transformers/es6/destructuring.js @@ -82,7 +82,7 @@ exports.Function = function (node, parent, scope, file) { var block = node.body; block.body = nodes.concat(block.body); - return node; + this.checkSelf(); }; export function CatchClause(node, parent, scope, file) { diff --git a/src/babel/transformation/transformers/es6/parameters.default.js b/src/babel/transformation/transformers/es6/parameters.default.js index 3637abba44..2a6d20a312 100644 --- a/src/babel/transformation/transformers/es6/parameters.default.js +++ b/src/babel/transformation/transformers/es6/parameters.default.js @@ -97,5 +97,5 @@ exports.Function = function (node, parent, scope, file) { node.body.body = body.concat(node.body.body); } - return node; + this.checkSelf(); }; diff --git a/src/babel/transformation/transformers/es6/parameters.rest.js b/src/babel/transformation/transformers/es6/parameters.rest.js index 94685ff293..631701a766 100644 --- a/src/babel/transformation/transformers/es6/parameters.rest.js +++ b/src/babel/transformation/transformers/es6/parameters.rest.js @@ -96,7 +96,8 @@ exports.Function = function (node, parent, scope, file) { candidate.replaceWith(argsId); optimizeMemberExpression(candidate.parent, node.params.length); } - return node; + this.checkSelf(); + return; } // @@ -137,5 +138,5 @@ exports.Function = function (node, parent, scope, file) { }); loop._blockHoist = node.params.length + 1; node.body.body.unshift(loop); - return node; + this.checkSelf(); }; diff --git a/src/babel/traversal/path/index.js b/src/babel/traversal/path/index.js index a2f5f9a2bd..4191cfee04 100644 --- a/src/babel/traversal/path/index.js +++ b/src/babel/traversal/path/index.js @@ -510,7 +510,7 @@ export default class TraversalPath { } if (this.node === replacement) { - throw new Error("You're trying to replace a node with itself which isn't allowed. If you're trying to do a transformer recache then use `this.checkSelf()`"); + throw new Error("You're trying to replace a node with itself which doesn't make any sense. If you're trying to do a transformer recache then use `this.checkSelf()`"); } // normalise inserting an entire AST diff --git a/test/core/fixtures/transformation/api/whitelist/actual.js b/test/core/fixtures/transformation/api/whitelist/actual.js index deaf9a91ef..8ec84a062e 100644 --- a/test/core/fixtures/transformation/api/whitelist/actual.js +++ b/test/core/fixtures/transformation/api/whitelist/actual.js @@ -1,5 +1,5 @@ class Test { constructor() { - arr.map(x => x * x); + arr.map(x => x * x); } }