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

Handle side effects correctly in rest params index expressions (#4348) #4674

Merged
merged 1 commit into from Oct 5, 2016

Conversation

motiz88
Copy link
Contributor

@motiz88 motiz88 commented Oct 5, 2016

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

This uses the scope.isPure heuristic to detect possible side effects of the constructed index expression, avoiding double execution as in #4348.

@codecov-io
Copy link

codecov-io commented Oct 5, 2016

Current coverage is 88.82% (diff: 100%)

Merging #4674 into master will increase coverage by 0.04%

@@             master      #4674   diff @@
==========================================
  Files           195        195          
  Lines         13780      13786     +6   
  Methods        1425       1425          
  Messages          0          0          
  Branches       3174       3175     +1   
==========================================
+ Hits          12235      12246    +11   
+ Misses         1545       1540     -5   
  Partials          0          0          

Powered by Codecov. Last update f5b5d8f...917ebcc

@motiz88 motiz88 added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label Oct 5, 2016
var _ref;

var index = 0;
return _ref = index++ + 0, arguments.length <= _ref ? undefined : arguments[_ref];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good? wondering where index++ + 0 is coming from (not part of this particular change)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the index of the rest parameter in the parameter list. If the function signature were e.g. function(a, b, ...values), it would be index++ + 2 instead.

Copy link
Member

@hzoo hzoo Oct 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, so we could make a change so that if it's 0 then don't add the + 0

#4692

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that would be a good idea.

@danez danez merged commit 0366d1a into babel:master Oct 5, 2016
@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

5 participants