New Type Solver [Beta]

Yeah, this one was really confusing. Why would it be trying to convert false to true? Not sure why an error would be raised here since TRUE and FALSE are both booleans

I didn’t even have memory issue, but autocomplete are broken for me.

The memory use should be more limited in the recent Studio update 644.
I would still suggest waiting for a few months more before enabling it on large projects with heavy use of strict typing as it can take a long time to complete, blocking auto-complete.

Can you please check if this still happens when you open your place in Studio version 644?

1 Like

this is a great update! however it always crashes when i open a place file :frowning:

1 Like

This feature was causing my Roblox Studio to crash on start-up, it would seem. Though only when opening a specific place, our team uses a lot of Luau so I’m assuming some collision somewhere caused something to crash. I’m not even sure how that would work but something to look into. Thanks :slight_smile: I’m excited for this change :fire: :heart:

1 Like

We definitely ran into a few new crashes that we’ve been working hard on fixing with the beta release! We suspect the 646 release should contain the last of the fixes for the big batch of crashes we’ve seen so far. So, I’d recommend folks who had crashes to try again next week once 646 has been released for a bit (it takes time for us to get all the flags on and so forth), and let us know if they’re experiencing crashes still.

It’s possible you’re encountering one that is new and we haven’t seen yet, and we’ll definitely keep an eye out for new crashes and investigate them as best as we can. If you experience one and want to help out, opening a DevForum bug report that includes a description of the crash, explicitly notes that it was in the New Type Solver Beta, and includes (privately) the attached place file would be tremendously useful in helping us diagnose and resolve the crash expediently! Cheers!

2 Likes

This beta seems to not work on my end sadly. Whenever opening any place, even the template baseplate, my memory usage continues to increase until it’s used all that’s available. I can still use Roblox Studio during this, but the IntelliSense and autocomplete fail to work.

3 Likes

I’ve seen a few issues

  1. math operations in different closures (most if not all)
--!strict
--!strict
local i: number = 0
task.defer(function()
	i = i + 1
	if i >= 3 then
		-- something
	end
end)

i + 1 and i >= 3 triggers warnings, however changing it to i += 1 solves both issues
if i remove the task.defer, it’s also fine.

So, typechecking for local variables in the same scope but seperate closure is very whack

  1. typeof() on generics
--!strict
local function sine<T>(amp: T, len: T, off: T, step: number?): T
	if type(amp) ~= "number" and type(amp) ~= "vector" then error(`invalid argument #1 (number or vector expected, got {typeof(amp)})`) end
	if typeof(len) ~= typeof(amp) then error(`invalid argument #2 ({typeof(amp)} expected, got {typeof(len)})`) end
	if typeof(off) ~= typeof(amp) then error(`invalid argument #2 ({typeof(amp)} expected, got {typeof(off)})`) end
	
	local x = step or os.clock() * 60
	if type(amp) == "number" then
		return amp * math.sin(x/len + 0.015707963267948967*off)
	elseif typeof(amp) == "Vector3" then
		if amp == Vector3.zero then return amp end
		return amp * Vector3.new(
			math.sin(x/len.X + 0.015707963267948967*off.X),
			math.sin(x/len.Y + 0.015707963267948967*off.Y),
			math.sin(x/len.Z + 0.015707963267948967*off.Z)
		)
	end
	
	if amp == Vector2.zero then return amp end
	return amp * Vector2.new(
		math.sin(x/len.X + 0.015707963267948967*off.X),
		math.sin(x/len.Y + 0.015707963267948967*off.Y)
	)
end

this entire code is littered with warnings

  • Type function instance union<*blocked-1234*, nil> is uninhabited on 3, 8, 10
  • Operator '== or ~=' could not be applied to operands of types string and *blocked-1234*; there is no corresponding overload for __eq on 4, 5
  • Type function instance intersect<T, number> depends on generic function parameters but does not appear in the function signature; this construct cannot be type-checked at this time on 9, 11-16, 19-23
  1. odd thing with tables
--!strict
local a = table.create(1)
a[1] = {}
table.insert(a[1], "test")

line 3 gives the error Type '{ }' could not be converted to 'nil'
line 4 gives the error None of the overloads for function that accept 2 arguments are compatible.
type solver seems to assume a[1] is nil for some reason
i first saw this issue with modules generated by Blink IDL, Queue and Events table create a ton of warnings with this same issue i just mentioned

2 Likes

big block number!
image

this happened after casting a table with index:

local t = {} :: index<typeof(tbl), T> -- where T is a generic

and running t through a function that would otherwise return a table:

local copy = table.clone(t) -- *blocked-xxxxxx* Function only returns 0 values, but 1 is required here
1 Like

Issue

Currently, if I try to create a type for a table without a specific key, the code completion does not show the indexes.

(doesn’t work either way with any or unknown)

image

  • (this wouldn’t work too as Table2 has not been defined yet)

image

  • Using string literal union doesn’t work

image

  • Neither does using another type works

image

Suggestion

  • Could we get a solution like in typescript and/or vscode, where there is Record<> and code completion even if the index is not specified?

image

1 Like

Unions are done using | not ,

{ ["apple" | "banana"]: string }

also you could type it as a struct

{
    apple: string,
    banana: string
}

also btw the solver not giving suggestions for { [string]: string } is a bug and should work

1 Like

What your wanting is, is a type provided by roblox that takes in a string and gives the equivalent instance type ie

function get_children<C>(class: C): { Instance<C> }

ene

you can technically do this rn, but instance.new doesnt work with typeof

function get_children<C>(class: C): { typeof(Instance.new("" :: C)) }

end

Note: you also need to use generics for this

One thing I have noticed is that the new type solver fails to recognise the types of function parameters when defining pre-typed functions.

2024-10-18_21-46-43

2024-10-18_21-48-41

For a bit of context: I’m using a unique type to override the RemoteFunction type, allowing me to get typechecking on remotes both on the server and client — without having to add types to the parameters more than once.

For some reason I no longer get autocompletion after enabling the “New Luau type solver” beta feature, is there anything I need to do to get it working again?

  • The key is not showing up in the autocomplete

  • But the value autocomplete still does

1 Like

Not sure if it is possible now but it’d be nice to be able to get an automcomplete in cases like this (very simplified, usually theres a bit more going on)
image
instead of having to specify it as a typeof({}) which i feel is a bit weird. (unless the table is specifically frozen, with table.freeze, i feel this should happen because its kind of untrue to whats actually going to happen)
image

i dont get any autocompletion anymore after enabling this beta. what gives? setting the “self” variable used to be so reliable, but now the self variable’s type is no longer recognized. neither do if statements work, checking for parts in the player character is worse now as every type is “unknown”

keyof has made using Luau so much more enjoyable omg :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: