Open jariji opened 5 months ago
The parse of the second is function foo(x)(x) end
, which was deemed likely not what you want in many situations, so the error was added intentionally to prevent people from getting the wrong thing accidentally.
function foo(x)(x) end
tries to define a function named foo(x)
but that doesn't seem like right parse for function foo(x) (x) end
which I would expect to be the same as function foo(x) x end
.
which I would expect to be the same
Yes and you're not the only, which is why this was made an error ;). More fundamentally, the parsing rules for signatures are the same as the parsing rules for regular calls. That could be changed of course, but that's a much more breaking (and also backwards incompatible) change. You can use a semicolon though: function foo(x); (x) end
I don't think this should be an error.