1.0.0
-
motoko (
moc)-
Shorter, simpler error messages for generic functions (#5650).
The compiler now tries to point to the first problematic expression in the function call, rather than the entire function call with type inference details.
Simple errors only mention closed types; verbose errors with unsolved type variables are only shown when necessary. -
Improved error messages for context dot: only the receiver type variables are solved, remaining type variables stay unsolved, not solved to
AnyorNon(#5634). -
Fixed the type instantiation hint to have the correct arity (#5634).
-
Improved type inference of the record update syntax (#5625).
-
New flag
--error-recoveryto enable reporting of multiple syntax errors (#5632). -
Improved solving and error messages for invariant type parameters (#5464).
Error messages now include suggested type instantiations when there is no principal solution.Invariant type parameters with bounds like
Int <: U <: Any(when the upper bound isAny) can now be solved by choosing the lower bound (Inthere) when it has no proper supertypes other thanAny.
This means that when choosing between exactly two solutions: the lower bound andAnyas the upper bound, the lower bound is chosen as the solution for the invariant type parameter (Uhere).
Symmetrically, with bounds likeNon <: U <: Nat(when the lower bound isNon), the upper bound (Nathere) is chosen when it has no proper subtypes other thanNon.For example, the following code now compiles without explicit type arguments:
import VarArray "mo:core/VarArray"; let varAr = [var 1, 2, 3]; let result = VarArray.map(varAr, func x = x : Int);
This compiles because the body of
func x = x : Inthas typeInt, which implies thatInt <: U <: Any.
SinceInthas no proper supertypes other thanAny, it can be chosen as the solution for the invariant type parameterU, resulting in the output type[var Int].However, note that if the function body was of type
Nat, it would not compile, becauseNatis a proper subtype ofInt(Nat <: Int).
In this case, there would be no principal solution withNat <: U <: Any, and the error message would suggest:Hint: Add explicit type instantiation, e.g. <Nat, Nat>The suggested type instantiation can be used to fix the code:
let result = VarArray.map<Nat, Nat>(varAr, func x = x);
Note that the error message suggests only one possible solution, but there may be alternatives. In the example above,
<Nat, Int>would also be a valid instantiation. -
Fixes type inference of deferred funcs that use
returnin their body (#5615).
Avoids confusing errors likeBool does not have expected type Tonreturnexpressions. Should type check successfully now. -
Add warning
M0239that warns when binding a unit()value byletorvar(#5599). -
Use
selfparameter, notSelftype, to enable contextual dot notation (#5574). -
Add (caffeine) warning
M0237(#5588).
Warns if explicit argument could have been inferred and omitted,
e.g.a.sort(Nat.compare)vsa.sort().
(allowed by default, warn with-W 0237). -
Add (caffeine) warning
M0236(#5584).
Warns if contextual dot notation could have been used,
e.g.Map.filter(map, ...)vsmap.filter(...).
Does not warn for binaryM.equals(e1, e2)orM.compareXXX(e1, e2).
(allowed by default, warn with-W 0236). -
Add (caffeine) deprecation code
M0235(#5583).
Deprecates any public types and values with special doc comment
/// @deprecated M0235.
(allowed by default, warn with-W 0235). -
Experimental support for
implicitargument declarations (#5517). -
Experimental support for Mixins (#5459).
-
bugfix: importing of
blob:file:URLs in subdirectories should work now (#5507, #5569). -
bugfix: escape
composite_queryfields on the Candid side, as it is a keyword (#5617). -
bugfix: implement Candid spec improvements (#5504, #5543, #5505).
May now cause rejection of certain type-incorrect Candid messages that were accepted before.
-