Re:Lune: Standalone Luau Runtime
by Moomoomoo309 on Wednesday May 21, 2025 @12:08PM
(#44052964)
Oh, Lua's type checker doesn't check function calls at all. Pass too few arguments? The rest are nil. Pass too many? The extras are dropped. An editor could check for it relatively easily (and some do, I think), but the language doesn't care at all.
Is this true of Luau as well, which is the dialect used here? Or are you talking about just Lua (which doesn't have a type checker at all) or LuaLS?
I'd check for myself but Luau's web demo seems to lack the most important feature of their dialect, type checking.
Re:Lune: Standalone Luau Runtime
by parenwielder on Wednesday May 21, 2025 @01:58PM
(#44054248)
Hi there, I’m from the Luau team. Just wanted to clarify that no, nothing they said about the type system is true of Luau. It reads like a comment about Lua’s runtime typechecking maybe (which is as limited as you’d expect from a dynamically typed language).
Thanks, I suspected as much!
Since you're here: Is it reasonably feasible for users to add declaration files for code exported from the host application? The lack of documentation got me stuck the last time I tried to embed Luau. Aside from that, I'm very excited about it!
Yes! As an embedder you can write definition and declaration files! Declaration files are usually named like `globals.d.luau` and have a slightly different syntax than regular Luau. But it's really easy to set up global def files that you can pass to luau-lsp. Atm for my Luau runtime (seal), I have a small globals.d.luau and just bundle all the stdlib type files in a typedefs folder that gets included alongside my binary: https://github.com/deviaze/seal/tree/main/.seal
This is just because definition files don't support doc comments yet (for hovers w/ luau-lsp)
> Lua's type checker
Lua has a type checker?
Do you mean colons for calling methods of an object, or semicolons at the end of lines?
Lua doesn't require semicolons at the end of lines. (Or lines at all.) Meanwhile accidentally using a period instead of a colon (field call instead of namecall) is completely semantically different (namecall passes self).
Re:Lune: Standalone Luau Runtime
by parenwielder on Wednesday May 21, 2025 @02:00PM
(#44054270)
Luau’s type system does arity checking and type checking for function calls, and even has a specialized error that detects when you probably meant to write a colon instead of a dot.
My main gripe with Lua (and thus Luau) is colons. It's so easy to forget them. Does the type checker catch this error? And if so, does it catch it every time, provided you always use types? If so, that could be good enough for me. Especially if it has strong LSP + VS Code support.