Skip to content

Releases: dfinity/motoko

0.16.1

25 Aug 15:28
d765134
Compare
Choose a tag to compare
  • motoko (moc)
    • bugfix: fix compile-time exception showing ??? type when using 'improved type inference' (#5423).

    • Allow inference of invariant type parameters, but only when the bound/solution is an 'isolated' type (meaning it has no proper subtypes nor supertypes other than Any/None) (#5359).
      This addresses the limitation mentioned in #5180.
      Examples of isolated types include all primitive types except Nat and Int, such as Bool, Text, Blob, Float, Char, Int32, etc.
      Nat and Int are not isolated because Nat is a subtype of Int (Nat <: Int).

      For example, the following code now works without explicit type arguments:

      import VarArray "mo:core/VarArray";
      let varAr = [var 1, 2, 3];
      let result = VarArray.map(varAr, func x = debug_show (x) # "!"); // [var Text]
    • ignore now warns when its argument has type async*, as it will have no effect (#5419).

    • bugfix: fix rare compiler crash when using a label and identifier of the same name in the same scope (#5283, #5412).

    • bugfix: moc now warns about parentheticals on async* calls, and makes sure that they get discarded (#5415).

0.16.0

19 Aug 09:13
3ec4d73
Compare
Choose a tag to compare
  • motoko (moc)

    • Breaking change: add new type constructor weak T for constructing weak references.

          Prim.allocWeakRef: <T>(value : T) -> weak T
          Prim.weakGet: <T>weak T -> ?(value : T)
          Prim.isLive: weak Any -> Bool

      A weak reference can only be allocated from a value whose type representation is always a heap reference; allowWeakRef will trap on values of other types.
      A weak reference does not count as a reference to its value and allows the collector to collect the value once no other references to it remain.
      weakGet will return null, and isLive will return false once the value of the reference has been collected by the garbage collector.
      The type constructor weak T is covariant.

      Weak reference operations are only supported with --enhanced-orthogonal-persistence and cannot be used with the classic compiler.

    • bugfix: the EOP dynamic stable compatibility check incorrectly rejected upgrades from Null to ?T (#5404).

    • More explanatory upgrade error messages with detailing of cause (#5391).

    • Improved type inference for calling generic functions (#5180).
      This means that type arguments can be omitted when calling generic functions in most common cases.
      For example:

      let ar = [1, 2, 3];
      Array.map(ar, func x = x * 2);  // Needs no explicit type arguments anymore!

      Previously, type arguments were usually required when there was an anonymous not annotated function in arguments.
      The reason being that the type inference algorithm cannot infer the type of funcs in general,
      e.g. func x = x * 2 cannot be inferred without knowing the type of x.

      Now, the improved type inference can handle such funcs when there is enough type information from other arguments.
      It works by splitting the type inference into two phases:

      1. In the first phase, it infers part of the instantiation from the non-func arguments.
        The goal is to infer all parameters of the func arguments, e.g. x in the example above.
        The ar argument in the example above is used to infer the partial instantiation Array.map<Nat, O>, leaving the second type argument O to be inferred in the second phase.
        With this partial instantiation, it knows that x : Nat.
      2. In the second phase, it completes the instantiation by inferring the bodies of the func arguments; assuming that all parameters were inferred in the first phase.
        In the example above, it knows that x : Nat, so inferring the body x * 2 will infer the type O to be Nat.
        With this, the full instantiation Array.map<Nat, Nat> is inferred, and the type arguments can be omitted.

      Limitations:

      • Invariant type parameters must be explicitly provided in most cases.
        e.g. VarArray.map must have the return type annotation:

        let result = VarArray.map<Nat, Nat>(varAr, func x = x * 2);

        Or the type of the result must be explicitly provided:

        let result : [var Nat] = VarArray.map(varAr, func x = x * 2);
      • When there is not enough type information from the non-func arguments, the type inference will not be able to infer the func arguments.
        However this is not a problem in most cases.

0.15.1

30 Jul 11:51
e0a80e3
Compare
Choose a tag to compare
  • motoko (moc)

    • bugfix: persistent imported actor classes incorrectly rejected as non-persistent (#5667).

    • Allow matching type fields of modules and objects in patterns (#5056)
      This allows importing a type from a module without requiring an indirection or extra binding.

      // What previously required indirection, ...
      import Result "mo:core/Result";
      type MyResult<Ok> = Result.Result<Ok, Text>;
      
      // or rebinding, ...
      import Result "mo:core/Result";
      type Result<Ok, Err> = Result.Result<Ok, Err>;
      type MyResult<Ok> = Result<Ok, Text>;
      
      // can now be written more concisely as:
      import { type Result } "mo:core/Result";
      type MyResult<Ok> = Result<Ok, Text>;
      

0.15.0

25 Jul 10:01
5643e16
Compare
Choose a tag to compare
  • motoko (moc)

    • Breaking change: the persistent keyword is now required on actors and actor classes (#5320, #5298).
      This is a transitional restriction to force users to declare transient declarations as transient and actor/actor classes as persistent.
      New error messages and warnings will iteratively guide you to insert transient and persistent as required, after which any stable keywords can be removed. Use the force.

      In the near future, the persistent keyword will be made optional again, and let and var declarations within actor and actor classes will be stable (by default) unless declared transient, inverting the previous default for non-persistent actors.
      The goal of this song and dance is to always default actor declarations to stable unless declared transient and make the persistent keyword redundant.

    • Breaking change: enhanced orthogonal persistence is now the default compilation mode for moc (#5305).
      Flag --enhanced-orthogonal-persistence is on by default.
      Users not willing or able to migrate their code can opt in to the behavior of moc prior to this release with the new flag --legacy-persistence.
      Flag --legacy-persistence is required to select the legacy --copying-gc (the previous default), --compacting-gc, or generational-gc.

      As a safeguard, to protect users from unwittingly, and irreversibly, upgrading from legacy to enhanced orthogonal persistence, such upgrades will fail unless the new code is compiled with flag --enhanced-orthogonal-persistence explicitly set.
      New projects should not require the flag at all (#5308) and will simply adopt enhanced mode.

      To recap, enhanced orthogonal persistence implements scalable and efficient orthogonal persistence (stable variables) for Motoko:

      • The Wasm main memory (heap) is retained on upgrade with new program versions directly picking up this state.
      • The Wasm main memory has been extended to 64-bit to scale as large as stable memory in the future.
      • The runtime system checks that data changes of new program versions are compatible with the old state.

      Implications:

      • Upgrades become extremely fast, only depending on the number of types, not on the number of heap objects.
      • Upgrades will no longer hit the IC instruction limit, even for maximum heap usage.
      • The change to 64-bit increases the memory demand on the heap, in worst case by a factor of two.
      • For step-wise release handling, the IC initially only offers a limited capacity of the 64-bit space (e.g. 4GB or 6GB), that will be gradually increased in future to the capacity of stable memory.
      • There is moderate performance regression of around 10% for normal execution due to combined related features (precise tagging, change to incremental GC, and handling of compile-time-known data).
      • The garbage collector is fixed to incremental GC and cannot be chosen.
      • Float.format(#hex prec, x) is no longer supported (expected to be very rarely used in practice).
      • The debug print format of NaN changes (originally nan).
    • Fixed file indices in the DWARF encoding of the debug_line section. This change is only relevant when using the -g flag (#5281).

    • Improved large array behavior under the incremental GC (#5314)

0.14.14

30 Jun 19:21
c85d17e
Compare
Choose a tag to compare
  • motoko (moc)

    • Lazy WASM imports: avoids unnecessary function imports from the runtime, improving compatibility with more runtime versions (#5276).

    • Improved stable compatibility error messages to be more concise and clear during canister upgrades (#5271).

0.14.13

17 Jun 14:52
f622ca4
Compare
Choose a tag to compare
  • motoko (moc)

    • Introduce await? to synchronize async futures, avoiding the commit point when already fulfilled (#5215).

    • Adds a Prim.Array_tabulateVar function, that allows faster initialization of mutable arrays (#5256).

    • optimization: accelerate IR type checking with caching of sub, lub and check_typ tests (#5260).
      Reduces need for -no-check-ir flag.

0.14.12

12 Jun 10:57
1b6a063
Compare
Choose a tag to compare
  • motoko (moc)

    • optimization: for --enhanced-orthogonal-persistence, reduce code-size and compile-time by sharing more static allocations (#5233, #5242).
    • bugfix: fix -fshared-code bug (#5230).
    • bugfix: avoid stack overflow and reduce code complexity for large eop canisters (#5218).
    • Added the rootKey primitive (#4994).

0.14.11

16 May 10:40
03d0a69
Compare
Choose a tag to compare
  • motoko (moc)

    • Enhance syntax error messages with examples and support find-references and go-to-definition
      functionality for fields in the language server (Serokell, Milestone-3) (#5076).

    • bugfix: mo-doc now correctly extracts record-patterned function arguments (#5128).

0.14.10

12 May 13:56
74b7366
Compare
Choose a tag to compare
  • motoko (moc)

    • Added new primitives for cost calculation:
      costCall, costCreateCanister, costHttpRequest, costSignWithEcdsa, costSignWithSchnorr (#5001).

0.14.9

25 Apr 13:51
da83616
Compare
Choose a tag to compare
  • motoko (moc)

    • Added new primitives for exploding fixed-width numbers to bytes:
      explodeNat16, explodeInt16, explodeNat32, explodeInt32, explodeNat64, explodeInt64 (#5057).