TASEmulators / BizHawk

BizHawk is a multi-system emulator written in C#. BizHawk provides nice features for casual gamers such as full screen, and joypad support in addition to full rerecording and debugging tools for all system cores.
http://tasvideos.org/BizHawk.html
Other
2.2k stars 385 forks source link

Improve Lua REPL handling of statements #4026

Open kalimag opened 2 months ago

kalimag commented 2 months ago

Rework the way the Lua console REPL executes commands

The old way first tries to execute $"console.log({rawCommand})", which prints out the values of an entered expression, but results in a syntax error if the command is a statement such as foo = 1. If the first attempt errors, it executes the raw command without the log call, so the command still works, but it's printing out confusing syntax error messages anyway. If the expression itself causes an error like "a" + 1 or string.format("%error"), it tries to run it twice and prints out two different errors.

The PR changes it so LuaLibraries.ExecuteString attempts to first parse the modified command without running it, and then only executes either the modified command or the raw command. This avoids unnecessary error messages, double execution of certain commands etc.

Check if completed: