4 ms·
I liked what I read, although the size of the original Lua embedded interpreter has a particular aesthetic that any type inference feature takes away (in return
by jll29 1y ago
I liked what I read, although the size of the original Lua embedded interpreter has a particular aesthetic that any type inference feature takes away (in return, you get type safety, it's a fair trade-off).
But when I tried it without reading to much, I got this (bug or feature)?
Code:
--!strict
local x: number = 2;
print("Hello World!")
x="test"
print(x)
Output:
Hello World!
test
There wasn't any error message or warning when I pressed the run button, and that certainly violated my expectations, regardless whether the code and behavior may be considered "correct" (=documented) or not.
- parenwielder 1y agoThe type system isn't set up to be "required" today. You can run code without typechecking, and if you used the demo or just ran the `luau` executable, that's what happened. In an embedded context, you could choose to e.g. require all code to typecheck before running the compiler on it, and then you'd get more of the experience you're probably expecting here, i.e. refusal to run because it didn't typecheck. This is part of how we exist in a world where we had millions of lines of Lua 5.1 code in the wild written by hundreds of thousands of developers that we suddenly, overnight, turned into Luau code.