prakhar1989 / JSJS

A strongly typed language for the web!
http://jsjs-lang.org
MIT License
40 stars 5 forks source link

Cannot have `val` declarations in return statements #45

Closed prakhar1989 closed 8 years ago

prakhar1989 commented 8 years ago

Having a val declaration, fucks up codegen since the JS that gets generated has return let which is invalid JS. Pattern-match on last expr and disallow this.

val x = if true then {
  val y = 10;
} else {
  val z = 20;
};

This generates the following JS -

   res_42828 = (function() { return let y = 10. })()
                                             ^^^

SyntaxError: Unexpected strict mode reserved word