js2coffee/js2coffee

if statement + single line ending by an empty function generate wrong coffeescript

gissehel opened this issue · 2 comments

if (mystruct) {
    mystruct.onAction = function() {};
}

generates

mystruct.onAction = ->  if mystruct

which generate a coffescript parse error. It should generates :

if mystruct
    mystruct.onAction = ->  

since implicit returns are merged, it should be read as

if (mystruct) {
  mystruct.onAction = function() {return};
}

which would produce a correct translation:

if mystruct
  mystruct.onAction = ->
    return

TODO: check #168

need to extend #168 add return also for empty functions