mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 19:34:27 -05:00
fixing return node squashing the possiblity of a ternary, when there should be one. Issue #475
This commit is contained in:
@@ -1290,10 +1290,10 @@ exports.IfNode: class IfNode extends BaseNode
|
||||
constructor: (condition, body, tags) ->
|
||||
@condition: condition
|
||||
@body: body
|
||||
@elseBody: null
|
||||
@elseBody: null
|
||||
@tags: tags or {}
|
||||
@condition: new OpNode('!', new ParentheticalNode(@condition)) if @tags.invert
|
||||
@isChain: false
|
||||
@isChain: false
|
||||
|
||||
bodyNode: -> @body?.unwrap()
|
||||
elseBodyNode: -> @elseBody?.unwrap()
|
||||
@@ -1345,9 +1345,12 @@ exports.IfNode: class IfNode extends BaseNode
|
||||
if @isStatement() then @compileStatement(o) else @compileTernary(o)
|
||||
|
||||
makeReturn: ->
|
||||
@body: and @ensureExpressions(@body.makeReturn())
|
||||
@elseBody: and @ensureExpressions(@elseBody.makeReturn())
|
||||
this
|
||||
if @isStatement()
|
||||
@body: and @ensureExpressions(@body.makeReturn())
|
||||
@elseBody: and @ensureExpressions(@elseBody.makeReturn())
|
||||
this
|
||||
else
|
||||
new ReturnNode this
|
||||
|
||||
ensureExpressions: (node) ->
|
||||
if node instanceof Expressions then node else new Expressions [node]
|
||||
|
||||
Reference in New Issue
Block a user