Docs typo in Language Quick Reference / Subtyping?

Some of the conditions for a shared function of type T: T1 -> T2 to be a subtype of another shared function U: U1 -> U2 are said to be:
U1 <: T1
T2 <: U2

This means that:

  • The arguments of T must be a supertype of the arguments of U
  • The return type of T must be a subtype of the return type of U

But when testing in Motoko Playground and DFX only the reverse condition allows upgrading without a backwards compatibility warning:
T1 <: U1
U2 <: T2

This last condition, where arguments can ‘grow’ in type and return types can only ‘shrink’ in type, is the one that makes most sense to clients and implementers of functions.


Oops my bad!

Spent a whole day just to discover that I had things switched up :joy:

I tried to upgrade T to U, but I had to to the opposite.

The docs are correct!