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

Revert "Differentiate object spread and non-spread properties (#9341)" #9379

Merged
merged 1 commit into from Jan 22, 2019

Conversation

@danez
Copy link
Member

danez commented Jan 22, 2019

This reverts commit 3ae5e79.

Q                       A
Fixed Issues? Fixes #9376
Patch: Bug Fix? y
Major: Breaking Change? reverse breaking change
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

Not sure what the actual issue is yet, but it seems to throw in some cases.

This reverts commit 3ae5e79.
@saschanaz

This comment has been minimized.

Copy link
Contributor

saschanaz commented Jan 22, 2019

It seems it's because some environments doesn't support Object.getOwnPropertyDescriptors.

@babel-bot

This comment has been minimized.

Copy link
Collaborator

babel-bot commented Jan 22, 2019

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/9854/

1 similar comment
@babel-bot

This comment has been minimized.

Copy link
Collaborator

babel-bot commented Jan 22, 2019

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/9854/

@nicolo-ribaudo

This comment has been minimized.

Copy link
Member

nicolo-ribaudo commented Jan 22, 2019

@saschanaz Do you want to open a PR moving these new changes to a new objectSpread2 helper? That way old code won't be broken by the new helper.

@saschanaz

This comment has been minimized.

Copy link
Contributor

saschanaz commented Jan 22, 2019

Yep, I'll do in a minute.

@loganfsmyth

This comment has been minimized.

Copy link
Member

loganfsmyth commented Jan 22, 2019

@saschanaz I wouldn't rush, we can review a second pass on this in a future release.

@loganfsmyth loganfsmyth merged commit 43b83f8 into babel:master Jan 22, 2019
4 checks passed
4 checks passed
babel/repl REPL preview is available
Details
ci/circleci Your tests passed on CircleCI!
Details
codecov/project 80.74% (target 80%)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@danez

This comment has been minimized.

Copy link
Member Author

danez commented Jan 22, 2019

The problem is for example this (which seems unlikely someone would do that, but there are probably other cases):

var a = { ...t, ...t };

in babel 7.2 this gets generated:

var a = _objectSpread({}, t, t);

in babel 7.3 this gets generated:

var a = _objectSpread({}, t, {}, t);
@danez danez deleted the danez:revert-spread-change branch Jan 22, 2019
@saschanaz

This comment has been minimized.

Copy link
Contributor

saschanaz commented Jan 22, 2019

I don't think adding {} there would cause any problem, though?

@nicolo-ribaudo

This comment has been minimized.

Copy link
Member

nicolo-ribaudo commented Jan 22, 2019

The problem is that, for this case:

var a = { ...x, ...null };

Babel 7.2 generates this code:

var a = _objectSpread({}, x, null);

But the Babel 7.3 helper expectes {} between x and null.

The problem isn't that new code doesn't work with the old helper; it's the opposite.

@danez

This comment has been minimized.

Copy link
Member Author

danez commented Jan 22, 2019

the problem is, that the code generated in 7.2 without {} still needs to work with the new helper.

var a = _objectSpread({}, t, t);

and as we do i%2 the first t will be in the if(i%2) clause of the helper the other t will be in the else branch. and if t is null or udnefined Object. getOwnPropertyDescriptors(null|undefined) will throw.

saschanaz added a commit to saschanaz/babel that referenced this pull request Jan 22, 2019
saschanaz added a commit to saschanaz/babel that referenced this pull request May 25, 2019
…babel#9341)" (babel#9379)"

This reverts commit 43b83f8.

Fix objectSpread helper breaking old codes

remove tests to regenerate later

renamed output

new name

try using word

add comment as requested

revert inline name changes

add 2 for consistency

Update packages/babel-helpers/src/helpers.js

Co-Authored-By: Daniel Tschinder <daniel@tschinder.de>
@lock lock bot added the outdated label Oct 4, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants
You can’t perform that action at this time.