Add a for .. from .. loop for generators, see #4306, #3832#4355
Merged
GeoffreyBooth merged 20 commits intojashkenas:masterfrom Nov 8, 2016
Merged
Add a for .. from .. loop for generators, see #4306, #3832#4355GeoffreyBooth merged 20 commits intojashkenas:masterfrom
for .. from .. loop for generators, see #4306, #3832#4355GeoffreyBooth merged 20 commits intojashkenas:masterfrom
Conversation
See explanation here: jashkenas#4306 (comment)
…om `master` as we can get away with
…formance improvements
…s.coffee; improve error message so that "own" is underlined
lydell
approved these changes
Nov 8, 2016
Collaborator
lydell
left a comment
There was a problem hiding this comment.
Good job!
The ownTag hack looks good to me.
This was referenced Nov 8, 2016
Merged
EsrefDurna
pushed a commit
to EsrefDurna/coffeescript
that referenced
this pull request
Nov 12, 2025
…enas#3832 (jashkenas#4355) * Added support for for-from loop, see jashkenas#3832 * for-from: remove extra newline and add support for ranges * for-from: tidy up the lexer * for-from: add support for patterns * for-from: fix bad alignment * for-from: add two more tests * for-from: fix test "for-from loops over generators" See explanation here: jashkenas#4306 (comment) * for-from: delete leftover console.log * Refactor the big `if` block in the lexer to be as minimal a change from `master` as we can get away with * Cleanup to make more idiomatic, remove trailing whitespace, minor performance improvements * for-from: move code from one file to another * for-from: clean up whitespace * for-from: lexer bikeshedding * Move "own is not supported in for-from loops" test into error_messages.coffee; improve error message so that "own" is underlined * Revert unnecessary changes, to minimize the lines of code modified by this PR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Trying to get #4306 over the finish line. There’s one significant change between that PR and this one: I moved the
"own is not supported in for-from loops"test intoerror_messages.coffee, and improved the error message generated for that error.Previously, code like
x for own x from [1, 2, 3]would throw the above error but withxunderlined. Since the error is about theown, it seems to me that theownis what should get emphasized. Getting the location data for theowntag (token?) entailed some trickery, though, as that token was basically discarded by the parser. See the new code added togrammar.coffeeregardingownTag—@lydell, is this kosher? Should I be calling thisownTokenor something else? Or is there a better way to get this location data intoFor?The other changes since #4306 involve fixing style and minimizing the impact of this PR, removing unnecessary changes.