diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b6bc66cc2..81891ce2db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,11 @@ _Note: Gaps between patch versions are faulty/broken releases._ +## 2.12.2 + + * **Internal** + * Exclude nodes in function parameters and catch clauses from `isReferenced` check. + ## 2.12.1 * **Internal** diff --git a/lib/6to5/types/index.js b/lib/6to5/types/index.js index ef433cd5b1..99308880ad 100644 --- a/lib/6to5/types/index.js +++ b/lib/6to5/types/index.js @@ -193,6 +193,17 @@ t.isReferenced = function (node, parent) { // we're a property key and we aren't computed so we aren't referenced if (t.isProperty(parent) && parent.key === node && !parent.computed) return false; + if (t.isFunction(parent)) { + // we're a function param + if (_.contains(parent.params, node)) return false; + + // we're a rest parameter + if (_.contains(parent.params, node)) return false; + } + + // we're a catch clause param + if (t.isCatchClause(parent) && parent.param === node) return false; + // we're a variable declarator id so we aren't referenced if (t.isVariableDeclarator(parent) && parent.id === node) return false;