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

Projects
None yet
5 participants
@motiz88
Contributor

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

This comment has been minimized.

Show comment
Hide comment
@codecov-io

codecov-io 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

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

@hzoo

hzoo approved these changes Oct 5, 2016

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

This comment has been minimized.

@hzoo

hzoo Oct 5, 2016

Member

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

@hzoo

hzoo Oct 5, 2016

Member

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

This comment has been minimized.

@mariusschulz

mariusschulz Oct 6, 2016

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.

@mariusschulz

mariusschulz Oct 6, 2016

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.

This comment has been minimized.

@hzoo

hzoo Oct 6, 2016

Member

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

#4692

@hzoo

hzoo Oct 6, 2016

Member

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

#4692

This comment has been minimized.

@mariusschulz

mariusschulz Oct 6, 2016

Yeah, that would be a good idea.

@mariusschulz

mariusschulz Oct 6, 2016

Yeah, that would be a good idea.

@danez danez merged commit 0366d1a into babel:master Oct 5, 2016

4 checks passed

ci/circleci Your tests passed on CircleCI!
Details
codecov/patch Coverage not affected when comparing f5b5d8f...917ebcc
Details
codecov/project 88.82% (+0.04%) compared to f5b5d8f
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment