mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 03:21:20 -05:00
Fixes Issue #603 -- a longstanding precedence issue involving prefix vs postfix if and unless, involving using the entire single-line if statment as an expression.
This commit is contained in:
@@ -64,10 +64,20 @@ ok result is undefined
|
||||
|
||||
# Return an if with no else.
|
||||
func = ->
|
||||
return (if false then callback())
|
||||
return if false then callback()
|
||||
|
||||
ok func() is null
|
||||
|
||||
func = ->
|
||||
return unless false then 100 else -100
|
||||
|
||||
ok func() is 100
|
||||
|
||||
ident = (x) -> x
|
||||
result = ident if false then 300 else 100
|
||||
|
||||
ok result is 100
|
||||
|
||||
|
||||
# If-to-ternary with instanceof requires parentheses (no comment).
|
||||
if {} instanceof Object
|
||||
|
||||
Reference in New Issue
Block a user