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

Fix destructuring assignment in arrow functions without block #8916

Merged
merged 1 commit into from Nov 25, 2018

Conversation

@RubenVerborgh
Copy link
Contributor

RubenVerborgh commented Oct 23, 2018

Q                       A
Fixed Issues? Fixes #8912
Patch: Bug Fix? 👍
Major: Breaking Change? 👎
Minor: New Feature? 👎
Tests Added + Pass? 👍
Documentation PR Link n/a
Any Dependency Changes? 👎
License MIT
  • In #8912, I reported that destructuring array assignment fails in arrow functions without a block.
  • This pull requests adds fixtures for that case, as well as the neighboring case of arrow functions with block.
  • It transforms such blockless functions into functions with a block and a return statement.
@babel-bot

This comment has been minimized.

Copy link
Collaborator

babel-bot commented Oct 23, 2018

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

Fixes 8912.
@RubenVerborgh

This comment has been minimized.

Copy link
Contributor Author

RubenVerborgh commented Oct 23, 2018

@loganfsmyth Wrapping the body means making the return statement explicit, and detecting this case would be more complex in path.ensureBlock() than it is at the point of generation. I'm therefore proposing a more simple change that fixes the problem directly in the destructuring plugin, where we can easily insert a return statement.

@RubenVerborgh RubenVerborgh changed the title Do not consider arrow functions without a block to be block parents Fix destructuring assignment in arrow functions without body Oct 23, 2018
@RubenVerborgh RubenVerborgh changed the title Fix destructuring assignment in arrow functions without body Fix destructuring assignment in arrow functions without block Oct 23, 2018
@danez
danez approved these changes Nov 2, 2018
@nicolo-ribaudo nicolo-ribaudo merged commit 9308c87 into babel:master Nov 25, 2018
4 checks passed
4 checks passed
babel/repl REPL preview is available
Details
ci/circleci Your tests passed on CircleCI!
Details
codecov/project 80.6% (target 80%)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@nicolo-ribaudo

This comment has been minimized.

Copy link
Member

nicolo-ribaudo commented Nov 25, 2018

Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
6 participants
You can’t perform that action at this time.