Skip to content

Lua 5.0 support#1263

Merged
Perryvw merged 77 commits intoTypeScriptToLua:masterfrom
YoRyan:lua5.0
Sep 3, 2022
Merged

Lua 5.0 support#1263
Perryvw merged 77 commits intoTypeScriptToLua:masterfrom
YoRyan:lua5.0

Conversation

@YoRyan
Copy link
Contributor

@YoRyan YoRyan commented Apr 20, 2022

This PR is a first attempt at introducing support for Lua 5.0, a version that some older games remain stuck on. It adds a 5.0 LuaTarget that triggers the appropriate syntax for variadic arguments and length-checking and modulo operations.

Lua 5.0, while mostly similar to 5.1, is not forwards-compatible; it is not possible to write a transpiler that is simultaneously compatible with both 5.0 and 5.1 syntax. Hence, if you choose to accept support for 5.0, you might also need to rename the "Universal" target to something more descriptive, like "5.1+".

Next steps: Adding tests, adding the appropriate type annotations for the 5.0 standard library to the lua-types package, and updating lualib to be 5.0-compatible.

@lolleko
Copy link
Member

lolleko commented Apr 20, 2022

I guess for this PR it is not yet required. But in the future we will need to add 5.0 to our WASM bindings, that way we can run tests for 5.0 properly. (TypeScriptToLua/lua-wasm-bindings#1)

Copy link
Member

@Perryvw Perryvw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me, just had some comments related to error messages and tests.

@YoRyan
Copy link
Contributor Author

YoRyan commented May 5, 2022

I've submitted the type declarations with pull request TypeScriptToLua/lua-types#59.

@YoRyan
Copy link
Contributor Author

YoRyan commented May 8, 2022

Okay, so here's a status update on this porting effort:

Still to do:

  • Lualib is currently only built for the universal target, which is not compatible with 5.0's syntax. We need to ship a second copy of lualib built for the 5.0 target.
  • Add bindings to test against the 5.0 interpreter (with @lolleko).
  • Update the documentation.

@YoRyan
Copy link
Contributor Author

YoRyan commented Aug 30, 2022

I managed to achieve different source files for different Lua targets with f390622! I used tsconfig.json's rootDirs feature while also stripping the sub-directories from the output paths as they are passed through the build plugin. This way, we have no version-specific branches or runtime checks.

As a bonus, we can now enable type checking of lualib against the Lua 5.0 types. This will work out-of-the-box once TypeScriptToLua/lua-types#75 is merged.

@YoRyan
Copy link
Contributor Author

YoRyan commented Aug 31, 2022

I've addressed all feedback and believe this is ready for a re-review.

You need TypeScriptToLua/lua-types#75 and TypeScriptToLua/lua-wasm-bindings#5 to get the tests to pass.

@Perryvw Perryvw merged commit 7497dbf into TypeScriptToLua:master Sep 3, 2022
@YoRyan YoRyan deleted the lua5.0 branch September 3, 2022 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants