Skip to content

Ability to re-enable try/catch in async/await for Lua 5.1 as a config setting? #1158

@MCJack123

Description

@MCJack123

I use TypeScriptToLua with the Minecraft mod ComputerCraft, which runs on a version of Lua 5.1 with various 5.2/5.3 library features backported. I noticed that TSTL 1.1.0 removes support for try/catch inside async/await functions on Lua 5.1, which makes sense because of the fact that pcall can't yield; however, both ComputerCraft, which uses the Cobalt VM (based on LuaJ) in Java, and my emulator CraftOS-PC, which uses a heavily patched version of Lua 5.1, do not suffer from this issue.

Would it be possible to add some sort of override inside tsconfig.json to allow exception handling inside async functions on 5.1? I do agree that the default behavior should be to disallow it, since standard Lua 5.1 is not compatible, but there are multiple 5.1 implementations that do support it, so it would be handy to be able to override that without having to switch to another version (which would then break switch) or edit the compiler manually.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions