Fixes #2274 -- allow @variables as loop variables
This commit is contained in:
parent
c06487c13b
commit
4fc9a345bb
|
@ -413,7 +413,7 @@
|
|||
})
|
||||
],
|
||||
ForValue: [
|
||||
o('Identifier'), o('Array', function() {
|
||||
o('Identifier'), o('ThisProperty'), o('Array', function() {
|
||||
return new Value($1);
|
||||
}), o('Object', function() {
|
||||
return new Value($1);
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -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
|
||||
]
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue