Can’t wait for the just-in-time compilation!
I believe it just tells the type checker thing what type the variable/function etc. is. Like string, number etc. And it can i guess restrict parameters of a function to a certain type. I don’t fully understand it yet, but this is what I took from it.
And also I do think the → is like the javascript =>
This is a question I’ve had on my mind for a while, will we ever see a standalone executable in the future for this? (Maybe even just a command line flag on the studio executable to only execute a script and return output without a full initialization)
LuaU sorta drifts from the normal lua 5.1 spec, so integration in tooling outside of studio wouldn’t necessarily be practical. For example if we want to use new features such as the new keyword “continue” we wouldn’t be able to.
I would love to see integration of this be used in more mainstream stuff such as Github/Gitlab CI.
Sort of just reporting these as I go through my codebase, but here’s another issue in non-strict mode:
The duplicate definition warning check does not take into account conditional branches.
All of this looks like static coding to me, is it going to improve performance?
Hi,
Good update but… please… DO NOT RELEASE IT.
Here’s the reason:
I get crashed everytime. This is literally the reason why I don’t want this.
Please, if Roblox is able to address this issue, I’ll be super pleased. Thank you!
And yes, I contacted Roblox Support.
It was actually released long ago, this time is just official, It is not that it is activated from now on.
Your problem has nothing to do with it.
Nevermind, I just turned off the beta feature, and I no longer get crashed.
Thank you for your response!
Epic release, the lighter and slightly changed syntax highlighting is cool too.
Is this !linter-tag
universal for everyone who’ll view the script in studio or just local, confused as to how that would work.
It’s just a comment in the script that changes the mode for the type checker, so it’s going to apply to everyone who opens the script.
Attempting to iterate over nil or a non-any type variable instantly crashes studio before execution.
examples
--!strict
for _ in pairs() do
end
--!strict
local a = function(x: string)
for _ in pairs(x) do
end
end
Please report all issues like this as bugs - we have to currently manually specify type information for certain types like Color3, so things slip through. The two issues above will be fixed!
Should be fixed after Studio restart, this one change wasn’t fully ready and was missed in a pre-release flurry of flags
Awesome! I added a third to that post as well just as you responded (Region3.new()
can take in 0 arguments in its constructor, but nonstrict mode reports it needs 2 arguments)
Will Luau ever become open-source? Now that this is fully released I think it’s a possibility. Who wouldn’t want to use Lua variable types in a HttpService backend for their Roblox game?
have you tried reinstalling ur studio? if not try following this steps to completely clear registries and stuff in case u have corrupt install
Since this is basically static coding, is it going to improve performance? If so, by how much and is it going to change how scripts run to be more like “compiled” scripts rather than “interpreted” scripts?
Could you create a separate report for these, preferably with source code pasted so that we can reproduce directly?
Wow, this is just going to be really helpful when scripting
Is it a bug that this code warns?
--!strict
local i:Part? = Instance.new"Part"
if typeof(i) == "Instance" then
print(i.Anchored) -- W000: Key 'Anchored' not found in class 'Instance'
end
If i
is an instance, it has to be a Part because a Part satisfies the condition but nil doesn’t.
This also looks like a bug
--!strict
local i:Part? = Instance.new"Part"
if i then
i:Destroy()
i = nil -- W000: Type 'Part' could not be converted to 'nil'
end
So does this mean that something like
--!strict
local str1:string = "abcde"
-- W000: Function only returns 1 values. 5 are required here
-- W000: Type 'nil|number' could not be converted into 'number'
local a:number,b:number,c:number,d:number,e:number = string.byte(str1,1,-1)
-- W000: Argument count mismatch. Function expects 1 argument, but 5 are specified
local str2:string = string.char(a,b,c,d,e)
Will no longer warn for mismatches of return values and arguments?
Errors for mixing union and intersection appear on the wrong line
Is there a reason this isn’t allowed? Presumably there could be precedence like and
/or
operators.
With function types what is the precedence of them with unions/intersections?
type a = (b) -> c&d
Could either be parsed as
type a = ((b) -> (c))&d
or
type a = (b) -> (c&d)
And this case happens even if you specify parenthesis around the return value
type a = ( b ) -> ( c ) & ( d )
-- | | |-------| |-------|
-- | | | type | | type |
-- |-------| |-----------------------|
-- | type | | type |
-- |----------------------------------------|
-- | type |
type a = ( b ) -> ( c ) & ( d )
-- |-------| |-------| | |
-- | type | | type | | |
-- |------------------------| |-------|
-- | type | | type |
-- |----------------------------------------|
-- | type |
Will there be documentation for types? It would help quite a lot for weird cases like precedence of function types and unions/intersections.