mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
Merge branch 'object_literals_in_compr' of https://github.com/rolftimmermans/coffee-script into rolftimmermans-object_literals_in_compr
Conflicts: test/objects.coffee
This commit is contained in:
commit
8248601b72
3 changed files with 8 additions and 2 deletions
|
@ -177,7 +177,7 @@
|
||||||
return this.scanTokens(function(token, i, tokens) {
|
return this.scanTokens(function(token, i, tokens) {
|
||||||
var callObject, current, next, prev, tag, _ref, _ref2, _ref3;
|
var callObject, current, next, prev, tag, _ref, _ref2, _ref3;
|
||||||
tag = token[0];
|
tag = token[0];
|
||||||
if (tag === 'CLASS' || tag === 'IF') noCall = true;
|
if (tag === 'CLASS' || tag === 'IF' || tag === 'FOR') noCall = true;
|
||||||
_ref = tokens.slice(i - 1, (i + 1) + 1 || 9e9), prev = _ref[0], current = _ref[1], next = _ref[2];
|
_ref = tokens.slice(i - 1, (i + 1) + 1 || 9e9), prev = _ref[0], current = _ref[1], next = _ref[2];
|
||||||
callObject = !noCall && tag === 'INDENT' && next && next.generated && next[0] === '{' && prev && (_ref2 = prev[0], __indexOf.call(IMPLICIT_FUNC, _ref2) >= 0);
|
callObject = !noCall && tag === 'INDENT' && next && next.generated && next[0] === '{' && prev && (_ref2 = prev[0], __indexOf.call(IMPLICIT_FUNC, _ref2) >= 0);
|
||||||
seenSingle = false;
|
seenSingle = false;
|
||||||
|
|
|
@ -167,7 +167,7 @@ class exports.Rewriter
|
||||||
|
|
||||||
@scanTokens (token, i, tokens) ->
|
@scanTokens (token, i, tokens) ->
|
||||||
tag = token[0]
|
tag = token[0]
|
||||||
noCall = yes if tag in ['CLASS', 'IF']
|
noCall = yes if tag in ['CLASS', 'IF', 'FOR']
|
||||||
[prev, current, next] = tokens[i - 1 .. i + 1]
|
[prev, current, next] = tokens[i - 1 .. i + 1]
|
||||||
callObject = not noCall and tag is 'INDENT' and
|
callObject = not noCall and tag is 'INDENT' and
|
||||||
next and next.generated and next[0] is '{' and
|
next and next.generated and next[0] is '{' and
|
||||||
|
|
|
@ -270,3 +270,9 @@ test "#1961, #1974, regression with compound assigning to an implicit object", -
|
||||||
|
|
||||||
eq obj.four, 4
|
eq obj.four, 4
|
||||||
|
|
||||||
|
test "#2007: Return object literal from comprehension", ->
|
||||||
|
y = for x in [1, 2]
|
||||||
|
foo: "foo"
|
||||||
|
bar: "bar"
|
||||||
|
|
||||||
|
eq y[0].foo, "foo"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue