Repeated tuple destructuring erases generic Int trait
ehllie opened this issue · 2 comments
ehllie commented
Running ante --show-types
on the following code:
a1, a2 = (1, 2, 3, 4)
b1, b2 = a2
c1, c2 = b2
produces the output:
a1 : i32
a2 : (i32, (i32, i32))
b1 : (forall i32. i32)
b2 : (forall i32 i32. (i32, i32))
c1 : (forall a. a)
c2 : (forall a. a)
However after setting concrete int types in the tuple
a1, a2 = (1i32, 2i32, 3i32, 4i32)
b1, b2 = a2
c1, c2 = b2
the compiler is able to correctly infer variable types:
a1 : i32
a2 : (i32, (i32, i32))
b1 : i32
b2 : (i32, i32)
c1 : i32
c2 : i32
jfecher commented
Worth noting this applies in general to any trait being solved resulting from a definition that is not generalized, with other definitions that are generalized:
trait Foo a with
foo: unit -> a
impl Foo u64 with
foo _ = 0
a = foo ()
b = a
c = b
Result of ante --check --show-types
:
a : u64
b : (forall u64. u64)
c : (forall a. a)
foo : (forall a b. (unit -> a can b))
given Foo a