Instances type doesn't respect inheritance, making it unusable even with typecasts

As of version 0.629, the recently added Instances global type doesn’t respect inheritance for items in it, completely making them unusable as it’s not possible to have an instance of type Instance. Declaring a type as {[number]: Instance} does not cause this issue and respects inheritance as per usual.
This occurs both in strict and nonstrict mode, and casting an instance to type Instance doesn’t work either.

Repro code and place file (in ServerScriptService):

instancesType.rbxl (52.5 KB)

--!strict
local instances:Instances = {}

--table.insert, no casts
table.insert(instances, Instance.new('Model'))

--newindex, casted to instance
instances[2] = Instance.new('RemoteEvent')::Instance

--table.move, casted to Instances
table.move({Instance.new('Part'), Instance.new('Folder')}::Instances, 1, 3, 3, instances)

--table.clone, casted to {[number]:Instance}
instances = table.clone({Instance.new('Part')}::{[number]:Instance})

Expected behavior

The Instances type acts as an alias for {[number]: Instance} and respects inheritence normally.

Thanks for the report. We actually added this type to the global typespace for testing purposes and don’t intend to keep it there forever (unless there’s a good reason to) so I would advise against using it in your code. That said, this is indeed a bug that will affect other types that we plan to add in the future so we’ll need to fix this regardless. I’ll follow-up once it’s been resolved.

1 Like