Skip to content
This repository was archived by the owner on May 19, 2018. It is now read-only.

Alow regex after "of" in for(...of...)#579

Merged
existentialism merged 2 commits intobabel:masterfrom
nicolo-ribaudo:for-of-regex
Aug 3, 2017
Merged

Alow regex after "of" in for(...of...)#579
existentialism merged 2 commits intobabel:masterfrom
nicolo-ribaudo:for-of-regex

Conversation

@nicolo-ribaudo
Copy link
Copy Markdown
Member

@nicolo-ribaudo nicolo-ribaudo commented Jun 15, 2017

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

I initially tried to set this.state.exprAllowed in the parser, after eating the "of" word (here), but then I decided to fix this bug directly in context.js.

This fix, teorically, has a "bug": in for (a++ of /foo/g);, the regex is parsed as a division because ++ can be followed by an expression. In practice this can't happen, because a++ is not a valid assignment target and thus babel throws before encountering /.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 15, 2017

Codecov Report

Merging #579 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #579      +/-   ##
==========================================
+ Coverage   98.14%   98.15%   +<.01%     
==========================================
  Files          22       22              
  Lines        3674     3677       +3     
  Branches     1024     1025       +1     
==========================================
+ Hits         3606     3609       +3     
  Misses         25       25              
  Partials       43       43
Flag Coverage Δ
#babel 80.82% <100%> (+0.01%) ⬆️
#babylon 96.81% <100%> (ø) ⬆️
Impacted Files Coverage Δ
src/tokenizer/context.js 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 6b4fba4...2e493fe. Read the comment docs.

@existentialism
Copy link
Copy Markdown
Member

This looks fine, but we may also want to ref acorn's fix, as there's also another case of handling contextual yield.

@nicolo-ribaudo
Copy link
Copy Markdown
Member Author

The bug with yield fixed by that commit already works in Babylon: https://astexplorer.net/#/gist/806e25352b11e858e13a0ccaf722816f/latest

@existentialism existentialism merged commit eee1a38 into babel:master Aug 3, 2017
@nicolo-ribaudo nicolo-ribaudo deleted the for-of-regex branch August 3, 2017 14:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants