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 evaluation with call expressions #4552

Merged
merged 2 commits into from Sep 24, 2016
Merged

Conversation

danez
Copy link
Member

@danez danez commented Sep 23, 2016

Q A
Bug fix? yes
Breaking change? no
New feature? no
Deprecations? no
Spec compliancy? no
Tests added/pass? yes
Fixed tickets #4054
License MIT
Doc PR

Do not optimize destructions with callExpressions or memberExpressions, as the call
might change the value of a variable that we are assigning to and memberExpressions might be getters with side effects.

Do not optimize destructions with callExpressions, as the call
might change the value of a variable that we are assigning to.

Fixes #4054
@danez danez added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label Sep 23, 2016
@codecov-io
Copy link

codecov-io commented Sep 23, 2016

Current coverage is 88.35% (diff: 100%)

Merging #4552 into master will increase coverage by <.01%

@@             master      #4552   diff @@
==========================================
  Files           194        194          
  Lines         13624      13626     +2   
  Methods        1427       1427          
  Messages          0          0          
  Branches       3151       3153     +2   
==========================================
+ Hits          12037      12039     +2   
  Misses         1587       1587          
  Partials          0          0          

Powered by Codecov. Last update d7533e8...b04cbdb

@overlookmotel
Copy link
Contributor

Please see my comments in original issue here: #4054 (comment)

members expressions might be getters who have side effects
@overlookmotel
Copy link
Contributor

Can I ask, does t.isMemberExpression(elem) return true if elem represents a variable (not a property of an object)?

As I mentioned in 2nd part of my comment #4054 (comment), I think in some (fairly niche) circumstances this can be unsafe to optimize too.

I don't know what babel's policy is on balancing optimization versus rock solid reliability. Perhaps the edge cases I'm pointing out are really pretty unlikely to ever occur in the real world, but hey, I value reliability over pretty much anything else.

@hzoo
Copy link
Member

hzoo commented Sep 24, 2016

@overlookmotel I think we would tend to lean on the reliability side. smaller/faster output can go under a loose mode option or on the opposite side a spec option?

@hzoo
Copy link
Member

hzoo commented Sep 24, 2016

lgtm can always make another pr for others

@hzoo hzoo merged commit c2d2702 into master Sep 24, 2016
@danez danez deleted the fix-destruct branch September 25, 2016 10:17
panagosg7 pushed a commit to panagosg7/babel that referenced this pull request Jan 17, 2017
* Fix destructuring evaluation with call expressions

Do not optimize destructions with callExpressions, as the call
might change the value of a variable that we are assigning to.

Fixes babel#4054

* Also deopt on member expressions

members expressions might be getters who have side effects
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 7, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants