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

Preserve empty for...of loops #3132

Merged
merged 13 commits into from Sep 26, 2019
Merged

Preserve empty for...of loops #3132

merged 13 commits into from Sep 26, 2019

Conversation

imatlopez
Copy link
Contributor

@imatlopez imatlopez commented Sep 26, 2019

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers: fixes #3126

Description

Since there is no proper support for Symbol.Iterator, drop the side effect (but don't remove) the algorithm such that iterators with side-effects are not omitted.

// this.left.hasEffectsWhenAssignedAtPath(EMPTY_PATH, options))) ||
// (this.right && this.right.hasEffects(options)) ||
// this.body.hasEffects(options.setIgnoreBreakStatements())
// );
Copy link
Member

Choose a reason for hiding this comment

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

Could you get rid of the commented code and commented import?

Copy link
Member

@lukastaegert lukastaegert left a comment

Choose a reason for hiding this comment

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

Looks good, just get rid of the commented code, we always have git to restore it.

: { done: true };

// assert later
global.foo = this.current;
Copy link
Member

Choose a reason for hiding this comment

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

A cooler way than mutating a global and testing our test isolation would be to export a mutable export let ... binding and checking that.

@lukastaegert
Copy link
Member

Also, I fear to greater part of work would be to adapt the existing test suite

@codecov
Copy link

codecov bot commented Sep 26, 2019

Codecov Report

Merging #3132 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3132      +/-   ##
==========================================
- Coverage   89.32%   89.32%   -0.01%     
==========================================
  Files         165      165              
  Lines        5732     5731       -1     
  Branches     1741     1740       -1     
==========================================
- Hits         5120     5119       -1     
  Misses        379      379              
  Partials      233      233
Impacted Files Coverage Δ
src/ast/nodes/ForOfStatement.ts 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bc5b98d...c2b48af. Read the comment docs.

Copy link
Member

@lukastaegert lukastaegert left a comment

Choose a reason for hiding this comment

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

Looks great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

treeshake incorrectly removes empty for..of and for await..of loops
2 participants