fir-lang / fir

MIT License
26 stars 3 forks source link

Monomorphiser cannot handle renamed type parameters #24

Open osa1 opened 1 month ago

osa1 commented 1 month ago

In the test ImplBounds1 we have this:

type A[T]:
    i: T

impl[T1: ToStr] A[T1]:
    fn test(self) =
        printStr(self.i.toStr())

fn main() = A(i = 123i32).test()

Here type of A(i = 123i32) is A[I32], so we monomorphise A with T => I32 in the type map.

When we monmorphise A.test, we have T => I32 in the type map, but type of self.i is T1, not T, so monomorphiser crashes when trying to monomorphise type T1, which doesn't exist.

Not sure how to fix this best..