Skip to content

Commit

Permalink
Fixes jashkenas#2274 -- allow @variables as loop variables
Browse files Browse the repository at this point in the history
  • Loading branch information
jashkenas committed Apr 24, 2012
1 parent c06487c commit 4fc9a34
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 105 deletions.
2 changes: 1 addition & 1 deletion lib/coffee-script/grammar.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

296 changes: 192 additions & 104 deletions lib/coffee-script/parser.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/grammar.coffee
Expand Up @@ -443,6 +443,7 @@ grammar =
# This enables support for pattern matching.
ForValue: [
o 'Identifier'
o 'ThisProperty'
o 'Array', -> new Value $1
o 'Object', -> new Value $1
]
Expand Down
11 changes: 11 additions & 0 deletions test/comprehensions.coffee
Expand Up @@ -499,3 +499,14 @@ test "#2007: Return object literal from comprehension", ->
eq 2, y.length
eq 1, y[0].x
eq 0, y[1].x

test "#2274: Allow @values as loop variables", ->
obj = {
item: null
method: ->
for @item in [1, 2, 3]
null
}
eq obj.item, null
obj.method()
eq obj.item, 3

0 comments on commit 4fc9a34

Please sign in to comment.