1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

Fixing issue number #486 (which is debatable). Allowing an unparenthesized if/else ternary as a trailing parameter to a call.

This commit is contained in:
Jeremy Ashkenas 2010-07-10 14:52:54 -04:00
parent 9ff8433f21
commit 15a2b7d69a
3 changed files with 9 additions and 2 deletions

View file

@ -168,7 +168,7 @@
stack.push(0);
return 1;
}
if (open && !token.generated && (!post || include(IMPLICIT_END, tag))) {
if (open && !token.generated && prev[0] !== ',' && (!post || include(IMPLICIT_END, tag))) {
j = 1;
while ((typeof (_d = (nx = this.tokens[i + j])) !== "undefined" && _d !== null) && include(IMPLICIT_END, nx[0])) {
j++;

View file

@ -137,7 +137,7 @@ exports.Rewriter: class Rewriter
return size
stack.push 0
return 1
if open and !token.generated and (!post or include(IMPLICIT_END, tag))
if open and !token.generated and prev[0] isnt ',' and (!post or include(IMPLICIT_END, tag))
j: 1; j++ while (nx: @tokens[i + j])? and include(IMPLICIT_END, nx[0])
if nx? and nx[0] is ','
@tokens.splice(i, 1) if tag is 'TERMINATOR'

View file

@ -157,6 +157,13 @@ result: sum ->
ok result is 20
# Implicit call with a trailing if statement as a param.
func: -> arguments[1]
result: func 'one', if false then 100 else 13
ok result is 13
# Test more function passing:
result: sum( ->
1 + 2