I believe I have found an issue with the Roblox Lua VM. The code below does not work in the command line or a script. Because of the semicolon, it is clear that (t) is just an expression and not a function call.
local t = {};
print('test');
(t).OnServerInvoke = nil;
error:
15:29:43.879 - ServerScriptService.Script:3: ambiguous syntax (function call x new statement) near '('
I was able to run the above code in an online Lua playground so I believe this issue is Roblox specific and not intended Lua error.
I just tested this, and was able to repro in studio when the Enable New Lua VM beta feature is off. When the beta feature is on, there is no issue.
It also appears to work in the command line for me, and Script analysis shows no errors.
Does command line always use the new Lua VM? game("FindFirstChild","Workspace") is valid in script with the beta feature off, but not in command line.
Edit: Using command line in edit mode appears to always use new Lua VM, but not in run mode.
Ok cool. This is a bug in the transpiler - in play mode when the old VM is still active, we use the new parser to parse the source and then generate vanilla Lua source. This process is lossy and doesn’t insert semicolons, leading to ambiguity. The transpiler is going to become unnecessary once the old VM gets removed (hopefully in a few weeks)