E4034#
Multiple possible record types detected, please add more annotation.
Erroneous Example#
fn main {
struct S { x : Int; y : Int }
struct T { x : Int; y : Int }
let c = { x: 2, y: 1 }
}
The example above tries to assign a record 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 record types detected: T, S, please add more annotation.
Suggestion#
Disambiguate the record type by adding a type annotation:
fn main {
struct S { x : Int; y : Int }
struct T { x : Int; y : Int }
let c : S = { x: 2, y: 1 }
let c2 = S::{ x : 2, y : 1 }
}