-
-
Notifications
You must be signed in to change notification settings - Fork 180
Basic Luau target
#1608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Basic Luau target
#1608
Conversation
Perryvw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, though the test run seems to indicate you forgot some stuff still.
It is not really possible to execute luau in our tests so that's fine, but looking at the change it might be nice if you add a luau-specific translation snapshot test containing a continue and ternary expression here: https://github.com/TypeScriptToLua/TypeScriptToLua/blob/master/test/translation/transformation.spec.ts
Also fixed not providing Luau to the `expectEachVersionExceptJit` function. It seems to work properly in the test suite but I need to make sure that this is intended or if the function should be renamed to something else (like `expectOnlyPUC`) and exclude Luau as well.
|
Added a transformation test although I'd like to make sure you're okay with the current implementations for two potential issues:
|
|
You can just run the tests locally with |
Now stored in separate folders. Future proof and doesn't feel gross. Also disabled Luau in expectEachVersionExceptJit. Ideally the function would be renamed but the change would be too large here (not necessary either).
|
Tests should be in a good state now |
Luau supports both math.atan & math.atan2 so having a certain result isn't important. Same goes for table.unpack and unpack. Had to pass an empty function for the continue case where luau wouldn't make a label at all since it has a proper continue statement.
| [tstl.LuaTarget.Lua53]: expectContinueGotoLabel, | ||
| [tstl.LuaTarget.Lua54]: expectContinueGotoLabel, | ||
| [tstl.LuaTarget.LuaJIT]: expectContinueGotoLabel, | ||
| [tstl.LuaTarget.Luau]: () => undefined, // TODO: This is N/A. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this this N/A? Shouldn't this be expecting the Luau continue statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That test specifically looks for the label or sentinel variable generated by the code for the other targets which isn't applicable to Luau since it just uses the builtin continue without a need for either.
Luauis a variant of Lua semi-recently becoming popular due to its open-sourcing and use by Roblox. It has a mix of features from 5.1-5.4 that make it not really fit into any traditional Lua version.Why
There's roblox-ts but that's another project and not everyone is using Luau for Roblox. We're using it for our own game engine - and I'm aware of other projects making use of Luau (the popular mlua rust library supports it, despite being a "lua" library)
Luaudoes include a type system, but it's not yet capable enough for my usecases. Plus, that's ignoring all the other benefits that Typescript brings.Changes
This PR:
LuauluaTargetcontinuestatement used solely by Luau.if <COND> then <X> else <Y>ternary operator used solely by Luau.There are other Luau-only features like type hints and compound assignment operators - but they could be done later on and aren't as pertinent
Please let me know how I should incorporate test cases - couldn't figure out how to do so myself, although I tested these features in a local project.