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:
parent
9ff8433f21
commit
15a2b7d69a
3 changed files with 9 additions and 2 deletions
|
@ -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++;
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue