-
Notifications
You must be signed in to change notification settings - Fork 468
Open
Labels
bugSomething isn't workingSomething isn't workingnew solverThis issue is specific to the new solver.This issue is specific to the new solver.
Description
The type function doesn't seem to run at all if the table passed into typeof is multi-depth.
Recreation:
local dict = {
["Hello"] = 1,
["World"] = 2
}
type dict = {
["Hello"]: number,
["World"]: number
}
type function indexes(ty)
if not ty:is("table") then
error("Can only call indexes on tables.")
end
local union = nil
for i,v in ty:properties() do
union = if union then types.unionof(union, i) else i
end
return if union then union else types.singleton(nil)
end
-- Works as expected: Returned type is Hello|World
local a:indexes<dict>
-- Works as expected: Returned type is Hello|World
local b:indexes<typeof(dict)>
local dict2 = {}
dict2.Hello = {1}
dict2.World = {2}
-- Doesn't work, Type returned is indexes<{ Hello:{number}, World: {Number} }>
local c:indexes<typeof(dict2)>
type dict2 = {
["Hello"]: {number},
["World"]: {number}
}
-- Works as expected: Returned type is Hello|World
local d:indexes<dict2>
Tested in Roblox Studio
If we add a print to the type function, all variables will get a type error expect c
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingnew solverThis issue is specific to the new solver.This issue is specific to the new solver.