luau icon indicating copy to clipboard operation
luau copied to clipboard

[New Solver] It does not register keys added to an intersection type

Open ExtremePro11299 opened this issue 8 months ago • 4 comments

-- Not showing all the variables
type playerFrame={Cardspace:cardspace --[[<Only this matters here]],Uno:ImageLabel&{TextLabel:TextLabel},CardAmount:TextLabel,DisplayName:TextLabel,DrawAmount:TextLabel,Elim:TextLabel,Time:TextLabel,read GetChildren:(Instance)->{Instance},Name:string,ClassName:"Frame",Position:UDim2}
type cardspace=Frame&{Turn:BoolValue,Parent:playerFrame}
-- Multiple lines
(playspace:FindFirstChild(plr.DisplayName)::playerFrame).Cardspace.Turn.Value=true
-- Type 'Frame & { Parent: playerFrame, Turn: BoolValue }' does not have key 'Turn'

ExtremePro11299 avatar Aug 30 '25 12:08 ExtremePro11299

Can you actually explain in English the behavior you expect to see and the behavior you're actually seeing here?

aatxe avatar Aug 30 '25 19:08 aatxe

playerFrame.Cardspace is of type cardspace, which has a key called Turn. But the type engine thinks that there is no such key as Turn.

ExtremePro11299 avatar Aug 31 '25 07:08 ExtremePro11299

In order for cardspace to have a key Turn, Frame would have to have a key Turn. An intersection type contains all (and only) the common bits between its component types.

aatxe avatar Sep 03 '25 18:09 aatxe

So I can't create an intersection type that would reflect an instance of a specific class and its children?

ExtremePro11299 avatar Sep 04 '25 16:09 ExtremePro11299