I could not reproduce the claimed bug. On which version does it exist?
Perhaps I wasn't clear enough, but `foo "bar"` is a valid construct, while `foo 42` is not, which is inconsistent. Either all literals should be allowed in such constructs or none.On 05/06/2019 23.13, John Erling Blad wrote:
> I wonder if the following could be changed
>
> args ::= ‘(’ [explist] ‘)’ | tableconstructor | LiteralString
>
> It is in the doc [1] and is somewhat limiting. It would be better if
> it included all literal values, and I can't see how this could be a
> problem, but perhaps there are some other reason why this is
> disallowed?
>
> [1] https://www.lua.org/manual/5.3/manual.html#8
Lua doesn't do static typing, which means that in order to somewhat
reliably detect typos at compile time, it needs a larger amount of
syntactically invalid programs.
There's already the problem that `local x, y z = 1, 2, 3` results in a
global variable `z = 1` and empty locals `x, y`. (I once spent far too
much time searching for this one, still painfully remembered…)
Permitting any literals as unparenthesized arguments would mean that
`local x, y, z = foo 23, 42` would be interpreted as a function call.
(Same for argument lists of function calls, multiple return values,
table constructors…)
I suspect that the trade-off between space/time saved on getting rid of
the parentheses vs. extra time spent searching typos that are now run
time instead of compile time errors is not in favor of this change.
-- nobody