E4034#
Multiple possible struct types detected, please add more annotation.
Erroneous Example#
pub struct S {
x : Int
y : Int
}
pub struct T {
x : Int
y : Int
}
pub fn make() -> Unit {
let _ = { x: 2, y: 1 }
}
The example above tries to assign a struct with fields x and y to a variable c,
but this field combination matches both S and T types, giving the following error on line 4:
Multiple possible struct types detected: T, S, please add more annotation.
Suggestion#
Disambiguate the struct type by adding a type annotation:
pub struct S {
x : Int
y : Int
}
pub struct T {
x : Int
y : Int
}
pub let c : S = { x: 2, y: 1 }
pub let c2 : S = S::{ x: 2, y: 1 }
pub let t : T = { x: 0, y: 0 }