dfinity / motoko

Simple high-level language for writing Internet Computer canisters

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Comparison of generic nullable with null doesn't compile.

AStepanov25 opened this issue · comments

The following code:

class A() {
  public func f() {};
};

func get<V>() : ?V {
  null;
};

assert get<A>() == null;

Causes:

mo:9.8-9.24: type error [M0060], operator is not defined for operand types
  ?A__9
and
  ?A__9

Note, that if A is without function it works.

Also:

func get<V>(t : ?V) : Bool {
  t == null;
};

Causes:

mo:2.3-2.12: type error [M0060], operator is not defined for operand types
  ?V
and
  ?V

moc = "0.10.3"

It's not a bug, there is no comparison for class A with function and generic class V.