dk00 / livescript-next

Enable latest ES features for LiveScript
https://lsn.netlify.com/
The Unlicense
39 stars 3 forks source link

Curried functions does not compile properly #14

Open danielo515 opened 6 years ago

danielo515 commented 6 years ago

Hello,

This is probably a problem because how LS compiles to AST. I have been checking and it produces the same AST for normal and curried functions, which is probably what confuses your compiler. Here is a small example, the following code produces:

add = (a, b) --> a + b

console.log add 3 4
let add;

add = function (a, b) {
  return a + b;
};

console.log(add(3, 4));

As you can see, the curry function is left behind. Of course this can be fixed by manually currying the function, which is not too bad

add = (a) -> (b) -> a + b

console.log add 3 <| 4

In fact I really like this because it looks a lot like HMS signatures ( I would love to remove the parens, but that is another story).

In any case, I think it's worth mentioning