There are two conditions I have noticed where my Luau types are incorrect. The first one is in this example:
The
CustomKeyframe
type is incorrectly coerced to a boolean, even though the actual part of the check I used was the
Broken
property of the object…
not the object itself
Another case where the type checker failed was in this example scenario:
Here the method’s types function just fine, but when placed in an
if
statement:
It appears to lose track of the type and casts the method call to
unknown
Expected behavior
The if
statement should be checking the type of the object and coercing / casting it appropriately given the nature of the clause, as opposed to not understanding method call types nor properties of custom objects. It also should not abstract away custom types, like expanding CustomKeyframe
into its full type information, it should just say the CustomKeyframe
type for self
1 Like
Additional examples found:
I believe this one, however, is not a related bug and is just due to the type checker not consolidating types by operands (i.e. expecting / type checking T
if and only if T
supports __le
like in C++, as opposed to expecting T
to take on all types, i.e. allowing T=Vector3
but not T=Instance
resulting in find<Instance>({...}, ...)
being an erroneous function call that results in a type error)
Thanks for the report! I am able to tell from some of the screenshots that you included that you are using the New Type Solver Beta, but in the future, it’s helpful to include this information explicitly to ensure that the bug report gets routed correctly. If you feel blocked by these issues in any way, feel free to turn off the beta. These do indeed appear to be actual bugs. The occurrence of a blocked type (like *blocked-443455*
) basically anywhere in an error is a dead giveaway that a bug has occurred. We are continuing to investigate and fix bugs in the New Solver Beta, including stuff with constraint solving not completing (the blocked types showing up everywhere) and refinements going awry (likely the cause of your initial bug report). If you’d like to help with this process, submitting code reproductions (rather than screenshots of code) helps us significantly.
The last error you received, about le<T, T>
, is basically just a limitation of the type system right now. We have to implement support for bounded polymorphism (sometimes called “generic type constraints” or “bounded generics” or a million other names) in order to be able to express accurately the type of your find
function because it does indeed not work on all types T
, but rather only on types that can be compared with <=
. Since we can’t actually express the bound yet, it creates the error you’re seeing instead.
1 Like
Additional cases found for constants:
In if
statement, constant is casted to unknown
, yet the object
variable seems to recognize that this is a VObj
, however in the else
clause, the type of object
becomes unknown, even though it should be able to deduce that it is no longer a VObj
Additional bug found:
--!strict
local fps: number = 0
game:GetService("RunService").PreSimulation:Connect(function(dt: number)
fps = (fps * 5 + 1/dt) / 6
-- or just fps = fps
end)
Error seems to persist regardless of how i try to re-word the math
No complicated code here, and not entirely sure where this t1
is coming from
This also happens sometimes