Skip to content

transform-es2015-parameters: arguments deoptimized when shadowed in nested function #5656

@jpommerening

Description

@jpommerening

This is a feature request (I think). Arguments are not optimized if an inner function shadows the name with a parameter (or rest parameters in my case).

Input Code

const log = (...args) => console.log(...args);

function test_opt(...args) {
  log(...args);
}

function test_deopt(...args) {
  const fn = (...args) => log(...args);
  fn(...args);
}

Babel Configuration (.babelrc, package.json, cli command)

{
  "presets": [ "es2015" ]
}

Expected vs. Current Behavior

I'd expect the code to be optimizable to use .apply( thisArg, arguments ) throughout.
However, in test_deopt the outer ...args gets copied just to be passed into the inner fn.
I can verify that the problem disappears if I rename either the ...args of test_deopt or of the fn arrow function.

Environment

software version(s)
Babel 6.24.1
node 6.9.5
npm N/A (yarn 0.20.3)
Operating System macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    Has PRoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions