E4063#

Type does not implement trait, although an impl is defined.

This error can be further divided into 5 cases:

  • Method is missing

  • Implementation is private

  • Method type mismatch

  • Constraints are not satisfied

  • Method contains unresolved type parameters

错误示例#

Method is missing#

trait Number {
  to_int(Self) -> Int
  to_float(Self) -> Float
}

type A Int

impl Number for A with to_int(self : A) -> Int {
//^~~~~~~~~~~~~~~
// Error: Type A does not implement trait Number, although an `impl` is defined.
// hint:
//   method to_float is missing.
  self._
}

建议#

Modify the code according to the hint provided along with the error message. For the example above, you can add the missing method to_float to type A.

impl Number for A with to_float(self : A) -> Float {
  self._.to_float()
}