4: attempt to call a nil value
If you append a semicolon to the end of line 3 however
(forcing the end of the statement?), the error is fixed.
I'm guessing this is a bug because, as I understand it,
semicolons are optional and only intended as syntactic
sugar.
As an exception to the free-format syntax of Lua, you
cannot put a line break before the '(' in a function call.
This restriction avoids some ambiguities in the language.
If you write
a = f
(g).x(a)
Lua would see that as a single statement, a = f(g).x(a).
So, if you want two statements, you must add a semi-colon
between them. If you actually want to call f, you must
remove the line break before (g).