js2coffee / js2coffee

Compile JavaScript to CoffeeScript

Home Page:http://js2.coffee

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect translation of return clause

jahbini opened this issue · comments

I put this code into js2coffee

function listen (el, event, handler,e) {
  var i,r;
  if (el.addEventListener) {
    if (el==="nala")
      return this.engine.run(e),r="select changes() as ar;",i=this.engine.exec(r),this.autoSave&&this.save(),{ar:i[0].values[0][0]}
    return   this.engine.run(e),r="select changes() as ar;",i=this.engine.exec(r),this.autoSave&&this.save(),{ar:i[0].values[0][0]}
  } else {
    return el.attachEvent("on" + event, function() {
      return handler.call(el);
    });
  }
}

And got this back:

listen = (el, event, handler, e) ->
  i = undefined
  r = undefined
  if el.addEventListener
    if el == 'nala'
      return @engine.run(e)
      r = 'select changes() as ar;'
      i = @engine.exec(r)
      @autoSave and @save()
      ar: i[0].values[0][0]

    @engine.run(e)
    r = 'select changes() as ar;'
    i = @engine.exec(r)
    @autoSave and @save()
    ar: i[0].values[0][0]
  else
    el.attachEvent 'on' + event, ->
      handler.call el

The return value is different for both identical return clauses, the one on the "nala" line looks incorrect.
help?