Type Model satisfies type Instance, however, when typed as arrays, they are considered to not be similar by the typesolver.
--!strict
local model: Model = Instance.new("Model")
local ins: Instance = model -- No Type Errors
local ModelArray: {Model} = {}
local InstanceArray: {Instance} = ModelArray -- Type '{Model}' could not be converted into '{Instance}' caused by: Property '[indexer value]' is not compatible. Type 'Model' could not be converted into 'Instance' in an invariant context
local typecastTest: {Instance} = ModelArray :: {Instance} -- Cannot cast '{Model}' into '{Instance}' because the types are unrelated
I also tried using custom types to see if they would also reproduce the bug, but no type errors occured.
--!strict
type Vec2 = {x: number, y: number}
type Vec3 = Vec2 & {z: number}
local Vec3Array: {Vec3} = {}
local Vec2Array: {Vec2} = Vec3Array
local v3: Vec3 = {x = 5, y = 2, z = 8}
local v2: Vec2 = v3
Since types Model and Instance are similar, their array types should also be similar, since every value in {Model} is an Instance.
I get a warning for local Vec2Array: {Vec2} = Vec3Array with it enabled. The part after that one, where a Vec3 is assigned to a Vec2, is intentional behavior.
You need to be using the New Solver to have all the latest features, such as Type Functions and numberous typechecking improvements. I am under the impression that the team will not be updating the old Solver in order to focus their efforts on the new version.
Hello, thank you for the report! The behavior for Instance and Model is expected, the linked post explains why this is. As for why the table types can be widened under the old solver, that is probably a bug, but we are not prioritizing work on the old solver.
I don’t use the new solver often because its pretty buggy, so I guess ill just anycast when I can.
We’d highly appreciate any bug reports for the new solver!