Problem
When a container has a known element type, mutating functions like push accept any value because their signatures use Any for the element parameter.
let x = [1]; // List<Int>
x.push(1.0); // Should be rejected — Float is not Int
for y in x { y + 1 } // Int overload selected, but y could be Float at runtime
Root cause
push is registered as push(List<Any>, Any). The analyser has no way to express that the second parameter must match the list's element type. This affects all generic mutation functions: push, push_front, push_back, insert, append, extend, etc.
Solution
This requires parametric polymorphism (generics) in the type system, so that push can be typed as push(List<T>, T). Special-casing individual functions is not the right approach.
Workaround
Users can use explicit type annotations to catch related issues at declaration or assignment sites, but the push call itself won't be caught.
Problem
When a container has a known element type, mutating functions like
pushaccept any value because their signatures useAnyfor the element parameter.Root cause
pushis registered aspush(List<Any>, Any). The analyser has no way to express that the second parameter must match the list's element type. This affects all generic mutation functions:push,push_front,push_back,insert,append,extend, etc.Solution
This requires parametric polymorphism (generics) in the type system, so that
pushcan be typed aspush(List<T>, T). Special-casing individual functions is not the right approach.Workaround
Users can use explicit type annotations to catch related issues at declaration or assignment sites, but the
pushcall itself won't be caught.