Lua Parsing Issue

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.

3 Likes

Does this occur when Luau VM beta is enabled?

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.

1 Like

It worked in the command line for me but then after running my game and stopping it, it no longer worked. Something else might have been weird there.

EDIT: Good catch! It does appear that the command line uses the new VM without the game running and doesn’t use it while the game is running?

I also do not get the error after enabling the beta VM.

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)

6 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.