E4016

E4016#

Please implement the required method for the type to use the infix operator.

Erroneous Example#

struct S { v : Int }

let s : S = { v: 3 }
let t = s + s

The example above tries to use the infix operator + on a type S that does not implement the required method op_add, giving the following error on line 4:

Please implement the method op_add for the type S to use the infix operator "+".

Suggestion#

Implement the required method for the type S:

struct S { v : Int }

let s : S = { v: 3 }
let t = s + s

fn S::op_add(self : S, other : S) -> S {
  { v: self.v + other.v }
}