When using the new type solver beta, some type info appears to linger even after type-casts, which can cause type errors that should be invalid.
See the following example for more info:
--!strict
--Example module that represents a tuple
local module
do
local a: {(Player)->()} = {}
local b: {[Player]:boolean} = {}
module = {a,b}
end
--a & b both resolve to {[Player]:boolean} | {(Player)->()},
-- but we know the hardcoded order of a and b.
--Attempt to typecast these values as 'any'
local a:any, b:any = unpack(module::any)
--Even though we typecasted as any, we still get the following warning from the original types;
--TypeError: None of the overloads for function that accept 2 arguments are compatible.
table.insert(a, function(plr)
print("Player object:", plr)
end)
Beta features:
- Luau type solver beta
- Incremental typechecking
Expected behavior
Type-casts should fully overwrite the type info, and later errors related to the original typings should not occur.