Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transform-object-rest-spread@6.19.0 duplicates function calls #4904

Closed
erikdesjardins opened this issue Nov 28, 2016 · 0 comments · Fixed by #5151
Closed

transform-object-rest-spread@6.19.0 duplicates function calls #4904

erikdesjardins opened this issue Nov 28, 2016 · 0 comments · Fixed by #5151
Labels
Has PR i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@erikdesjardins
Copy link
Contributor

erikdesjardins commented Nov 28, 2016

Input Code

const { x, ...y } = foo();

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

{
  "dependencies": {
    "babel-plugin-transform-object-rest-spread": "^6.19.0",
    "babel-cli": "^6.18.0"
  },
  "scripts": {
    "build": "babel --plugins transform-object-rest-spread src.js > out.js"
  }
}

Expected Behavior

const _ref = foo();
const { x } = _ref;
const y = _objectWithoutProperties(_ref, ["x"]);

Current Behavior

const { x } = foo();
const y = _objectWithoutProperties(foo(), ["x"]);

Context

Your Environment

software version
Babel babel-core@6.18.2, babel-cli@6.18.0, babel-plugin-transform-object-rest-spread@6.19.0
node 4.1.2, 6.5.0, 7.1.0
npm 2.14.4, 3.10.3, 3.10.9
Operating System Windows, Linux

It also does something crazy for this code 😜 ... c gets hoisted out of the arrow function and then the above bug duplicates the entire thing:

in:

const { a } = foo(({ b, ...c }) => {
  console.log(b, c);
});

out:

const { a } = foo(({ b }) => {
  console.log(b, c);
});
const c = _objectWithoutProperties(foo(({ b }) => {
  console.log(b, c);
}), ["b"]);
@xtuc xtuc added the i: bug label Dec 3, 2016
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 5, 2018
@lock lock bot locked as resolved and limited conversation to collaborators May 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Has PR i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants