You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hopefully I'm describing this correctly? I'm not familiar with the terminology used for types at an implementation level.
Consider the following script:
When trying to perform a generalized iteration over Node.GetAllNodes() in another script...
--!strictlocalNode=require(script.Parent.Node)
fori, genericinNode.GetAllNodes() dogeneric:Print()
end
...the following type error is emitted:
Type Error: (5,2) Type 'INode' could not be converted into 'INode'
caused by:
Type 'Node' from 'game.Workspace.Node' could not be converted into 'Node' from 'game.Workspace.Node'
caused by:
Property 'new' is not compatible.
Type
'(a) -> Node'
could not be converted into
'<T>(T) -> Node'; different number of generic type parameters
This issue can be worked around if I use pairs(Node.GetAllNodes()) or next, Node.GetAllNodes() instead. I've been observing this issue for as long as I've been using metatable types, though I never hammered down a direct simple repro until recently.
The text was updated successfully, but these errors were encountered:
MaximumADHD
changed the title
Generic functions not being inferred correctly in generalized iteration?
Generic functions not being typed correctly in generalized iteration?
Feb 14, 2024
Hopefully I'm describing this correctly? I'm not familiar with the terminology used for types at an implementation level.
Consider the following script:
When trying to perform a generalized iteration over Node.GetAllNodes() in another script...
...the following type error is emitted:
This issue can be worked around if I use
pairs(Node.GetAllNodes())
ornext, Node.GetAllNodes()
instead. I've been observing this issue for as long as I've been using metatable types, though I never hammered down a direct simple repro until recently.The text was updated successfully, but these errors were encountered: