Hello,
Lua 5.5 BNF grammar contains rules for "local" and "global" names:
stat ::= ‘;’ |
<snipped>
local attnamelist [‘=’ explist] |
global attnamelist |
<snipped>
I'm confused by the absence of the "[‘=’ explist]" in the rule for "global".
It seems that the code below is syntactically incorrect:
global a, b = 1, 2
or
global a = 1
or
global <const> a = 1
However, the chunks above are successfully accepted by Lua:
$ ./lua -e "global a, b = 1, 2"; echo $?
0
$ ./lua -e "global a = 1"; echo $?
0
$ ./lua -e "global <const> a = 1"; echo $?
0
Where is a truth?
Also, it is suspicious that chunk below does not work:
$ ./lua -e "global a; print()"
./lua: (command line):1: variable 'print' not declared
The same with "local" works fine:
$ ./lua -e "local a; print()"; echo $?
0
Version: PUC Rio Lua 5.5, 84938a7d2b680d2d28ec99606e84fe712efd9a69