ic-mops 0.26.3 → 0.26.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/test.js ADDED
@@ -0,0 +1,1411 @@
1
+ // const markdownHeadings = require('markdown-headings');
2
+ import markdownHeadings from 'markdown-headings';
3
+ let str = `
4
+ # Motoko compiler changelog
5
+
6
+ ## 0.9.8 (2023-08-11)
7
+
8
+ * motoko (\`moc\`)
9
+
10
+ * Added numerical type conversions between adjacent fixed-width types (#4139).
11
+
12
+ * Administrative: legacy-named release artefacts are no longer created (#4111).
13
+
14
+ ## 0.9.7 (2023-07-18)
15
+
16
+ * motoko (\`moc\`)
17
+
18
+ * Performance improvement: lower the default allocation for bignums (#4102).
19
+
20
+ * Performance improvement: generate better code for pattern matches on some small variants (#4093).
21
+
22
+ * bugfix: don't crash on import of Candid composite queries (#4128).
23
+
24
+ ## 0.9.6 (2023-07-07)
25
+
26
+ * motoko (\`moc\`)
27
+
28
+ * Allow canister controllers to call the \`__motoko_stable_var_info\` query endpoint (#4103).
29
+ (Previously only self-queries were permitted.)
30
+
31
+ * Performance improvement: reduced cycle consumption for allocating objects (#4095).
32
+
33
+ * bugfix: reduced memory consumption in the Motoko Playground (#4106).
34
+
35
+ ## 0.9.5 (2023-07-05)
36
+
37
+ * motoko (\`moc\`)
38
+
39
+ * Allow identifiers in \`or\`-patterns (#3807).
40
+ Bindings in alternatives must mention the same identifiers and have compatible types:
41
+ \`\`\` Motoko
42
+ let verbose = switch result {
43
+ case (#ok) "All is good!";
44
+ case (#warning why or #error why) "There is some problem: " # why;
45
+ }
46
+ \`\`\`
47
+
48
+ * Performance improvement: improved cycle consumption allocating fixed-size objects (#4064).
49
+ Benchmarks indicate up to 10% less cycles burned for allocation-heavy code,
50
+ and 2.5% savings in realistic applications.
51
+
52
+ * Administrative: binary build artefacts are now available according to standard naming
53
+ conventions (thanks to EnzoPlayer0ne) (#3997).
54
+ Please consider transitioning to downloading binaries following the new scheme,
55
+ as legacy naming will be discontinued at some point in the future.
56
+
57
+ ## 0.9.4 (2023-07-01)
58
+
59
+ * motoko (\`moc\`)
60
+
61
+ * Allow multiline text literals (#3995).
62
+ For example,
63
+ \`\`\`
64
+ "A horse walks into a bar.
65
+ The barman says: \`Why the long face?\`"
66
+ \`\`\`
67
+
68
+ parses as:
69
+ \`\`\`
70
+ "A horse walks into a bar.\nThe barman says: \`Why the long face?\`"
71
+ \`\`\`
72
+
73
+ * Added pipe operator \`<exp1> |> <exp2>\` and placeholder expression \`_\` (#3987).
74
+ For example:
75
+ \`\`\` motoko
76
+ Iter.range(0, 10) |>
77
+ Iter.toList _ |>
78
+ List.filter<Nat>(_, func n { n % 3 == 0 }) |>
79
+ { multiples = _ };
80
+ \`\`\`
81
+
82
+ may, according to taste, be a more readable rendition of:
83
+ \`\`\` motoko
84
+ { multiples =
85
+ List.filter<Nat>(
86
+ Iter.toList(Iter.range(0, 10)),
87
+ func n { n % 3 == 0 }) };
88
+ \`\`\`
89
+
90
+ However, beware the change of evaluation order for code with side-effects.
91
+
92
+ * BREAKING CHANGE (Minor):
93
+
94
+ New keyword \`composite\` allows one to declare Internet Computer *composite queries* (#4003).
95
+
96
+ For example,
97
+ \`\`\` motoko
98
+ public shared composite query func sum(counters : [Counter]) : async Nat {
99
+ var sum = 0;
100
+ for (counter in counters.vals()) {
101
+ sum += await counter.peek();
102
+ };
103
+ sum
104
+ }
105
+ \`\`\`
106
+
107
+ has type:
108
+ \`\`\` motoko
109
+ shared composite query [Counter] -> async Nat
110
+ \`\`\`
111
+
112
+ and can call both \`query\` and other \`composite query\` functions.
113
+
114
+ See the documentation for full details.
115
+
116
+ * Allow canister imports of Candid service constructors, ignoring the service arguments to
117
+ import the instantiated service instead (with a warning) (#4041).
118
+
119
+ * Allow optional terminal semicolons in Candid imports (#4042).
120
+
121
+ * bugfix: allow signed float literals as static expressions in modules (#4063).
122
+
123
+ * bugfix: improved reporting of patterns with record types in error messages (#4002).
124
+
125
+ * motoko-base
126
+
127
+ * Added more \`Array\` (and \`Text\`) utility functions (thanks to roman-kashitsyn) (dfinity/motoko-base⁠#564).
128
+
129
+ ## 0.9.3 (2023-06-19)
130
+
131
+ * motoko (\`moc\`)
132
+
133
+ * Added fields \`sender_canister_version\` for actor class version tracking (#4036).
134
+
135
+ ## 0.9.2 (2023-06-10)
136
+
137
+ * motoko (\`moc\`)
138
+
139
+ * BREAKING CHANGE (Minor):
140
+
141
+ \`or\`-patterns in function definitions cannot be inferred any more. The new error
142
+ message suggests to add a type annotation instead. This became necessary in order
143
+ to avoid potentially unsound types (#4012).
144
+
145
+ * Added implementation for \`ic0.canister_version\` as a primitive (#4027).
146
+
147
+ * Added a more efficient \`Prim.blobCompare\` (thanks to nomeata) (#4009).
148
+
149
+ * bugfix: minor error in grammar for \`async*\` expressions (#4005).
150
+
151
+ * motoko-base
152
+
153
+ * Add \`Principal.isController\` function (dfinity/motoko-base#558).
154
+
155
+ ## 0.9.1 (2023-05-15)
156
+
157
+ * motoko (\`moc\`)
158
+
159
+ * Added implementation for \`ic0.is_controller\` as a primitive (#3935).
160
+
161
+ * Added ability to enable the new incremental GC in the Motoko Playground (#3976).
162
+
163
+ ## 0.9.0 (2023-05-12)
164
+
165
+ * motoko (\`moc\`)
166
+
167
+ * **For beta testing:** Add a new _incremental_ GC, enabled with new moc flag \`--incremental-gc\` (#3837).
168
+ The incremental garbage collector is designed to scale for large program heap sizes.
169
+
170
+ The GC distributes its workload across multiple steps, called increments, that each pause the mutator
171
+ (user's program) for only a limited amount of time. As a result, the GC work can fit within the instruction-limited
172
+ IC messages, regardless of the heap size and the object structures.
173
+
174
+ According to GC benchmark measurements, the incremental GC is more efficient than the existing copying, compacting,
175
+ and generational GC in the following regards:
176
+ * Scalability: Able to use the full heap space, 3x more object allocations on average.
177
+ * Shorter interruptions: The GC pause has a maximum limit that is up to 10x shorter.
178
+ * Lower runtimes: The number of executed instructions is reduced by 10% on average (compared to the copying GC).
179
+ * Less GC overhead: The amount of GC work in proportion to the user's program work drops by 10-16%.
180
+
181
+ The GC incurs a moderate memory overhead: The allocated WASM memory has been measured to be 9% higher
182
+ on average compared to the copying GC, which is the current default GC.
183
+
184
+ To activate the incremental GC under \`dfx\`, the following command-line argument needs to be specified in \`dfx.json\`:
185
+
186
+ \`\`\`
187
+ ...
188
+ "type" : "motoko"
189
+ ...
190
+ "args" : "--incremental-gc"
191
+ ...
192
+ \`\`\`
193
+
194
+ * bugfix: \`array.vals()\` now returns a working iterator for mutable arrays (#3497, #3967).
195
+
196
+ ## 0.8.8 (2023-05-02)
197
+
198
+ * motoko (\`moc\`)
199
+
200
+ * Performance improvement: optimised code generation for pattern matching that cannot fail (#3957).
201
+
202
+ ## 0.8.7 (2023-04-06)
203
+
204
+ * motoko (\`moc\`)
205
+
206
+ * Added ability to \`mo-doc\` for rendering documentation of nested modules (#3918).
207
+
208
+ * bugfix: when re-adding recurrent timers, skip over past expirations (#3871).
209
+
210
+ * bugfix: eliminated crash compiling local \`async\` functions that pattern match on arguments (#3910, #3916).
211
+
212
+ ## 0.8.6 (2023-04-01)
213
+
214
+ * motoko (\`moc\`)
215
+
216
+ * bugfix: avoid compiler crash (regression) when \`let\`-matching on constant variants (#3901, #3903).
217
+
218
+ * Performance improvement: improved cycle usage when receiving messages (#3893).
219
+
220
+ ## 0.8.5 (2023-03-20)
221
+
222
+ * motoko (\`moc\`)
223
+
224
+ * Performance improvement: Values of variant type that are compile-time known
225
+ are relegated to the static heap now and don't get allocated each time (#3878).
226
+
227
+ * bugfix: the global timer expiration callback was called unnecessarily in the
228
+ default mechanism (#3883).
229
+
230
+ ## 0.8.4 (2023-03-11)
231
+
232
+ * motoko (\`moc\`)
233
+
234
+ * Performance improvement: UTF-8 coding and validation is now properly tail recursive (#3842).
235
+
236
+ * Performance improvement: eliminated bounds checking for certain array accesses (thanks to nomeata) (#3853).
237
+
238
+ * Performance improvement: optimized \`{array, blob, text}.size()\` operations (thanks to nomeata) (#3863).
239
+
240
+ * Performance improvement: efficient tuple results in \`switch\` statements (thanks to nomeata) (#3865).
241
+
242
+ * Performance improvement: more efficient untagging operation (#3873).
243
+
244
+ * bugfix: restored a grammar regression caused by \`let-else\` (#3869).
245
+
246
+ * motoko-base
247
+
248
+ * Add \`Array.subArray\` function (dfinity/motoko-base#445).
249
+
250
+ * BREAKING CHANGE (Minor)
251
+
252
+ Optimized \`AssocList.{replace, find}\` to avoid unnecessary allocation (dfinity/motoko-base#535, dfinity/motoko-base#539).
253
+ Note: this subtly changes the order in which the key-value pairs occur after replacement. May affect other containers that use \`AssocList\`.
254
+
255
+ * Performance improvement: Optimized deletion for \`Trie\`/\`TrieMap\` (dfinity/motoko-base#525).
256
+
257
+ ## 0.8.3 (2023-02-24)
258
+
259
+ * motoko (\`moc\`)
260
+
261
+ * new 'let-else' construct for handling pattern-match failure (#3836).
262
+ This is a frequently asked-for feature that allows to change the control-flow
263
+ of programs when pattern-match failure occurs, thus providing a means against
264
+ the famous "pyramid of doom" issue. A common example is look-ups:
265
+ \`\`\` Motoko
266
+ shared func getUser(user : Text) : async Id {
267
+ let ?id = Map.get(users, user) else { throw Error.reject("no such user") };
268
+ id
269
+ }
270
+ \`\`\`
271
+ Similarly, an expression like
272
+ \`\`\` Motoko
273
+ (label v : Bool { let <pat> = <exp> else break v false; true })
274
+ \`\`\`
275
+ evaluates to a \`Bool\`, signifying whether \`<pat>\` matches \`<exp>\`.
276
+
277
+ * Improve recursive deserialization capacity to match recursive serialization capacity by reducing
278
+ Wasm stack consumption (#3809).
279
+ Because of the bounds on recursion depth imposed by fixed-size stack, the
280
+ advice remains the same: avoid deeply nested recursive data structures.
281
+ Think "shallow trees good, very long lists bad".
282
+
283
+ * bugfix: stack overflow in UTF-8 encode/decode for \`moc.js\` (#3825).
284
+
285
+ * motoko-base
286
+
287
+ * add missing \`unshare : Tree<K, V> -> ()\` method to class \`RBTree<K, V>\`
288
+ to restore objects from saved state (dfinity/motoko-base#532).
289
+
290
+ ## 0.8.2 (2023-02-17)
291
+
292
+ * motoko (\`moc\`)
293
+
294
+ * Add compiler flag \`--rts-stack-pages <n>\` to override default number of
295
+ pages dedicated to fixed runtime system stack. Now defaults to 32 pages
296
+ (2MiB) (up from previous 2 pages/128KiB) (#3782).
297
+ In emergencies, increasing this setting may improve your ability to deserialize
298
+ deeply nested Candid or stable variable data.
299
+
300
+ * Add stack overflow detection utilising reserved page (#3793).
301
+
302
+ * Performance improvement: heap allocator speedup (#3090, #3790).
303
+
304
+ * bugfix: avoid more heap-out-bounds errors during deserialization of stable variables
305
+ by increasing default runtime system stack from 128KiB to 2MiB (#3782).
306
+ _Note_: this is a partial fix, as issues with stack growth remain.
307
+
308
+ * motoko-base
309
+
310
+ * bugfix: non-leaky deletion for \`RBTree\` (dfinity/motoko-base#524).
311
+
312
+ ## 0.8.1 (2023-02-03)
313
+
314
+ * motoko (\`moc\`)
315
+
316
+ * Performance improvement: faster heap allocation (#3765).
317
+
318
+ * bugfix: \`async\` returns involving abbreviated tuple types no longer crash the compiler (#3740, #3741).
319
+
320
+ * bugfix: avoid quadratic code expansion due to imported, but unused, actor classes (#3758).
321
+
322
+ ## 0.8.0 (2023-01-27)
323
+
324
+ * motoko (\`moc\`)
325
+
326
+ * BREAKING CHANGE
327
+
328
+ Motoko now implements Candid 1.4 (dfinity/candid#311).
329
+
330
+ In particular, when deserializing an actor or function reference,
331
+ Motoko will now first check that the type of the deserialized reference
332
+ is a subtype of the expected type and act accordingly.
333
+
334
+ Very few users should be affected by this change in behaviour.
335
+
336
+ * BREAKING CHANGE
337
+
338
+ Failure to send a message no longer traps but, instead, throws a catchable \`Error\` with new error code \`#call_error\` (#3630).
339
+
340
+ On the IC, the act of making a call to a canister function can fail, so that the call cannot (and will not be) performed.
341
+ This can happen due to a lack of canister resources, typically because the local message queue for the destination canister is full,
342
+ or because performing the call would reduce the current cycle balance of the calling canister to a level below its freezing threshold.
343
+ Such call failures are now reported by throwing an \`Error\` with new \`ErrorCode\` \`#call_error { err_code = n }\`,
344
+ where \`n\` is the non-zero \`err_code\` value returned by the IC.
345
+ Like other errors, call errors can be caught and handled using \`try ... catch ...\` expressions, if desired.
346
+
347
+ The constructs that now throw call errors, instead of trapping as with previous version of Motoko are:
348
+ * calls to \`shared\` functions (including oneway functions that return \`()\`).
349
+ These involve sending a message to another canister, and can fail when the queue for the destination canister is full.
350
+ * calls to local functions with return type \`async\`. These involve sending a message to self, and can fail when the local queue for sends to self is full.
351
+ * \`async\` expressions. These involve sending a message to self, and can fail when the local queue for sends to self is full.
352
+ * \`await\` expressions. These can fail on awaiting an already completed future, which requires sending a message to self to suspend and commit state.
353
+
354
+ (On the other hand, \`async*\` (being delayed) cannot throw, and evaluating \`await*\` will at most propagate an error from its argument but not, in itself, throw.)
355
+
356
+ Note that exiting a function call via an uncaught throw, rather than a trap, will commit any state changes and currently queued messages.
357
+ The previous behaviour of trapping would, instead, discard, such changes.
358
+
359
+ To appreciate the change in semantics, consider the following example:
360
+
361
+ \`\`\` motoko
362
+ actor {
363
+ var count = 0;
364
+ public func inc() : async () {
365
+ count += 1;
366
+ };
367
+ public func repeat() : async () {
368
+ loop {
369
+ ignore inc();
370
+ }
371
+ };
372
+ public func repeatUntil() : async () {
373
+ try {
374
+ loop {
375
+ ignore inc();
376
+ }
377
+ } catch (e) {
378
+ }
379
+ };
380
+ }
381
+ \`\`\`
382
+
383
+ In previous releases of Motoko, calling \`repeat()\` and \`repeatUntil()\` would trap, leaving \`count\` at \`0\`, because
384
+ each infinite loop would eventually exhaust the message queue and issue a trap, rolling back the effects of each call.
385
+ With this release of Motoko, calling \`repeat()\` will enqueue several \`inc()\` messages (around 500), then \`throw\` an \`Error\`
386
+ and exit with the error result, incrementing the \`count\` several times (asynchronously).
387
+ Calling \`repeatUntil()\` will also enqueue several \`inc()\` messages (around 500) but the error is caught so the call returns,
388
+ still incrementing \`count\` several times (asynchronously).
389
+
390
+ The previous semantics of trapping on call errors can be enabled with compiler option \`--trap-on-call-error\`, if desired,
391
+ or selectively emulated by forcing a trap (e.g. \`assert false\`) when an error is caught.
392
+
393
+ For example,
394
+
395
+ \`\`\` motoko
396
+ public func allOrNothing() : async () {
397
+ try {
398
+ loop {
399
+ ignore inc();
400
+ }
401
+ } catch (e) {
402
+ assert false; // trap!
403
+ }
404
+ };
405
+ \`\`\`
406
+
407
+ Calling \`allOrNothing()\` will not send any messages: the loop exits with an error on queue full,
408
+ the error is caught, but \`assert false\` traps so all queued \`inc()\` messages are aborted.
409
+
410
+ * bugfix: system method \`inspect\` involving message with single tuple argument no longer crashes the compiler (#3732, #3733).
411
+
412
+ ## 0.7.6 (2023-01-20)
413
+
414
+ * motoko (\`moc\`)
415
+
416
+ * Added support for \`ManagementCanister.raw_rand\` in interpreters (#3693).
417
+
418
+ * Added preliminary Viper support for \`old\` expressions in specifications and calls to private methods (#3675).
419
+
420
+ * bugfix: in the default timer mechanism \`cancelTimer\` sometimes wouldn't actually stop a recurring timer (#3695).
421
+
422
+ * bugfix: zero negation for floating point numbers in compiled code (#3676).
423
+
424
+ * motoko-base
425
+
426
+ * Add user-facing timer functionality (dfinity/motoko-base#474).
427
+
428
+ * Add \`Array.size\` (dfinity/motoko-base#486, dfinity/motoko-base#494).
429
+
430
+ * Add \`TrieSet\` methods \`isEmpty\`, \`isSubset\` (dfinity/motoko-base#503).
431
+
432
+ * BREAKING CHANGES (Minor):
433
+ - renamed \`Float.neq\` to \`Float.neg\` (this was a misspelling)
434
+ - renamed \`Nat.neq\` to \`Nat.neg\` (this was a misspelling)
435
+ - removed second argument from \`bitnot\` (this was an oversight)
436
+
437
+ * bugfix: \`Random.Finite.coin\` didn't use entropy correctly (dfinity/motoko-base#500).
438
+
439
+ * bugfix: \`Trie.mergeDisjoint\` (dfinity/motoko-base#505).
440
+
441
+ * bugfix: \`TrieSet.equals\` (dfinity/motoko-base#503).
442
+
443
+ * Various documentation fixes and API usage examples.
444
+
445
+ ## 0.7.5 (2022-12-23)
446
+
447
+ * motoko (\`moc\`)
448
+
449
+ * Add new primitives for a default timer mechanism (#3542). These are
450
+ \`\`\` Motoko
451
+ setTimer : (delayNanos : Nat64, recurring : Bool, job : () -> async ()) -> (id : Nat)
452
+ cancelTimer : (id : Nat) -> ()
453
+ \`\`\`
454
+ By defining a \`system func timer\` the default mechanism can now be overridden by a custom
455
+ implementation. Additionally by supplying the command-line flag \`-no-timer\` all aspects
456
+ of timers can be suppressed, e.g. for space- or security-sensitive purposes, thus effectively
457
+ reverting canisters to the pre-timers era.
458
+
459
+ * bugfix: silence bogus cascading errors in stable compatibility check (#3645).
460
+
461
+ ## 0.7.4 (2022-12-07)
462
+
463
+ * motoko (\`moc\`)
464
+
465
+ * Add new keywords \`async*\` and \`await*\` (note the \`*\`) for efficient abstraction of asynchronous code (#3609).
466
+ \`\`\`
467
+ <typ> ::= ...
468
+ async* <typ> delayed, asynchronous computation
469
+ <exp> ::= ...
470
+ async* <block-or-exp> delay an asynchronous computation
471
+ await* <block-or-exp> execute a delayed computation (only in async, async*)
472
+ \`\`\`
473
+ This avoids the resource consumption and latency of \`async\`/\`await\` by only committing state and suspending execution
474
+ when necessary in the \`await*\`-ed computation, not necessarily at the \`await*\` itself.
475
+
476
+ WARNING: Unlike \`async\`/\`await\`:
477
+ * an \`async*\` value has no effect unless \`await*\`-ed;
478
+ * each \`await*\` of the same \`async*\` value repeats its effects.
479
+
480
+ This feature is experimental and may evolve in future. Use with discretion.
481
+ See the [manual](doc/md/language-manual.md) for details.
482
+
483
+ * Suppress GC during IC \`canister_heartbeat\`, deferring any GC to the scheduled Motoko \`heartbeat\` \`system\` method (#3623).
484
+ This is a temporary workaround, to be removed once DTS is supported for \`canister_heartbeat\` itself (#3622).
485
+
486
+ * Add a new _generational_ GC, enabled with new moc flag \`--generational-gc\` (#3495).
487
+ The generational garbage collector optimizes for fast reclamation of short-lived objects.
488
+ New objects are allocated in a young generation that is more frequently collected than the older objects
489
+ that have already survived a GC run.
490
+
491
+ For many cases, the generational GC is more efficient than the existing compacting GC and copying GCs:
492
+ * Lower runtimes: Less number of executed instructions on average.
493
+ * Shorter interruptions: Young generation collection entails shorter program interruptions.
494
+
495
+ To activate the generational GC under \`dfx\`, the following command-line argument needs to be specified in \`dfx.json\`:
496
+
497
+ \`\`\`
498
+ ...
499
+ "type" : "motoko"
500
+ ...
501
+ "args" : "--generational-gc"
502
+ ...
503
+ \`\`\`
504
+
505
+ * \`moc.js\` : add trampoline and step limiter to interpreter, avoiding (some) stackoverflows and
506
+ hangs (#3618, #3541).
507
+ Enables execution of larger examples on web pages.
508
+
509
+ * BREAKING CHANGE (Minor):
510
+
511
+ Consider records with mutable fields as non-static (#3586).
512
+ Consequently, an imported library declaring a mutable record is now
513
+ rejected, not accepted, to be consistent with the declarations of
514
+ mutable fields and mutable objects.
515
+
516
+ * Experimental Viper integration by compiling a very narrow subset of
517
+ Motoko to the verification intermediate language. See \`src/viper/README.md\`
518
+ and the PR for details. (#3477).
519
+
520
+ * motoko-base
521
+
522
+ * Unit tests for Trie and fix for \`disj\` (dfinity/motoko-base#438).
523
+
524
+ * Respect Trie structure in \`filter\` (dfinity/motoko-base#431, dfinity/motoko-base#438).
525
+
526
+ * Array module reimplementation, tests and documentation (dfinity/motoko-base#425,dfinity/motoko-base#432).
527
+
528
+ ## 0.7.3 (2022-11-01)
529
+
530
+ * motoko (\`moc\`)
531
+
532
+ * Statically reject shared functions and function types with type parameters (#3519, #3522).
533
+
534
+ * Performance improvement: \`Array.init\` and \`Array.tabulate\` (#3526).
535
+
536
+ * motoko-base
537
+
538
+ * Add some examples to \`Buffer\` library documentation (dfinity/motoko-base#420).
539
+
540
+ * Fix another bug in \`Buffer\` library affecting \`filterEntries\` (dfinity/motoko-base#422).
541
+
542
+ ## 0.7.2 (2022-10-25)
543
+
544
+ * motoko-base
545
+
546
+ * Fix bugs in \`Buffer\` library affecting \`remove\` and \`filterEntries\` (dfinity/motoko-base#419).
547
+
548
+ ## 0.7.1 (2022-10-24)
549
+
550
+ * motoko (\`moc\`)
551
+
552
+ * Halve (default ir-checking) compilation times by optimizing type comparison and hashing (#3463)
553
+
554
+ * Add support for type components in object type syntax (#3457, also fixes #3449)
555
+ \`\`\` motoko
556
+ type Record = { type T = Nat; x : Nat};
557
+ \`\`\`
558
+ is now legal.
559
+ Note the definition of \`T\` is neither recursive, nor bound in \`x : Nat\`,
560
+ but can refer to an existing recursive type declared in an outer scope.
561
+
562
+ * motoko-base
563
+
564
+ * Optimized and extended \`Buffer\` library (dfinity/motoko-base#417).
565
+
566
+ ## 0.7.0 (2022-08-25)
567
+
568
+ * motoko (\`moc\`)
569
+
570
+ * BREAKING CHANGE (Minor):
571
+ Adds new syntax for merging records (objects) and
572
+ adding/overwriting fields. The expression
573
+ \`\`\` motoko
574
+ { baseA and baseB with field1 = val1; field2 = val2 }
575
+ \`\`\`
576
+ creates a new record by joining all (statically known) fields from
577
+ \`baseA/B\` and the explicitly specified \`field1/2\`.
578
+ This is a _breaking change_, as a new keyword \`with\` has been added.
579
+ Restrictions for ambiguous and \`var\` fields from bases apply. (#3084)
580
+
581
+ * Add new support for installing actor class instances on the IC,
582
+ enabling specification of canister settings, install, upgrade and
583
+ reinstall. (#3386)
584
+
585
+ A new expression
586
+
587
+ \`\`\` bnf
588
+ (system <exp> . <id>)
589
+ \`\`\`
590
+ where \`<exp>\` is an imported library and \`<id>\` is the name of
591
+ an actor class, accesses a secondary constructor of the class
592
+ that takes an additional argument controlling the installation.
593
+
594
+ For example,
595
+ \`\`\` motoko
596
+ await (system Lib.Node)(#upgrade a)(i);
597
+ \`\`\`
598
+ upgrades actor \`a\` with the code for a new instance of class \`Lib.Node\`,
599
+ passing constructor argument \`(i)\`.
600
+
601
+ * Performance improvements for assigment-heavy code (thanks to nomeata) (#3406)
602
+
603
+ ## 0.6.30 (2022-08-11)
604
+
605
+ * motoko (\`moc\`)
606
+
607
+ * add primitives
608
+ \`\`\`motoko
609
+ shiftLeft : (Nat, Nat32) -> Nat
610
+ shiftRight : (Nat, Nat32) -> Nat
611
+ \`\`\`
612
+ for efficiently multiplying/dividing a \`Nat\` by a power of 2
613
+ (#3112)
614
+
615
+ * add primitives
616
+ \`\`\`motoko
617
+ rts_mutator_instructions : () -> Nat
618
+ rts_collector_instructions : () -> Nat
619
+ \`\`\`
620
+ to report approximate IC instruction costs of the last message
621
+ due to mutation (computation) and collection (GC), respectively (#3381)
622
+
623
+ * motoko-base
624
+
625
+ * Add
626
+ \`\`\`motoko
627
+ Buffer.fromArray
628
+ Buffer.fromVarArray
629
+ \`\`\`
630
+ for efficiently adding an array to a \`Buffer\`
631
+ (dfinity/motoko-base#389)
632
+
633
+ * Add
634
+ \`\`\`motoko
635
+ Iter.sort : (xs : Iter<A>, compare : (A, A) -> Order) : Iter<A>
636
+ \`\`\`
637
+ for sorting an \`Iter\` given a comparison function
638
+ (dfinity/motoko-base#406)
639
+
640
+ * Performance: \`HashMap\` now avoids re-computing hashes on \`resize\`
641
+ (dfinity/motoko-base#394)
642
+
643
+ ## 0.6.29 (2022-06-10)
644
+
645
+ * motoko (\`moc\`)
646
+
647
+ * The language server now supports explicit symbol imports (thanks
648
+ to rvanasa) (#3282)
649
+ * The language server now has improved support for navigating to
650
+ definitions in external modules (thanks to rvanasa) (#3263)
651
+ * Added a primitive \`textCompare\` allowing more efficient three-way
652
+ \`Text\` comparisons (#3298)
653
+ * Fixed a typing bug with annotated, recursive records (#3268)
654
+
655
+ * motoko-base
656
+
657
+ * Add
658
+ \`\`\`motoko
659
+ ExperimentalInternetComputer.countInstruction : (comp : () -> ()) -> Nat64
660
+ \`\`\`
661
+ to count the Wasm instructions performed during execution of \`comp()\` (dfinity/motoko-base#381)
662
+
663
+ * Add
664
+ \`\`\`motoko
665
+ ExperimentalStableMemory.stableVarQuery : () -> (shared query () -> async {size : Nat64})
666
+ \`\`\`
667
+ for estimating stable variable storage requirements during upgrade
668
+ (dfinity/motoko-base#365)
669
+ * Performance improvement to \`Text.compare\` (dfinity/motoko-base#382)
670
+
671
+ ## 0.6.28 (2022-05-19)
672
+
673
+ * motoko (\`moc\`)
674
+
675
+ * Add \`to_candid\`, \`from_candid\` language constructs for Candid serialization to/from Blobs (#3155)
676
+ * New \`system\` field 'inspect' for accepting/declining canister ingress messages (see doc) (#3210)
677
+
678
+ ## 0.6.27 (2022-05-04)
679
+
680
+ * motoko (\`moc\`)
681
+
682
+ * Importing modules by relative path is now more robust (#3215).
683
+ * Performance: persisting stable variables to stable memory is now
684
+ performed in streaming fashion, reducing heap consumption and
685
+ copying during an upgrade (#3149).
686
+ * Performance: local 32- and 64-bit numeric values are now stored in
687
+ using unboxed form when possible (thanks to nomeata) (#3207).
688
+
689
+ * motoko-base
690
+
691
+ * Fixed a bug in \`Trie.filter\` (and \`Trie.mapFilter\`) which could
692
+ lead to missing matches in some cases (dfinity/motoko-base#371).
693
+
694
+ ## 0.6.26 (2022-04-20)
695
+
696
+ * motoko (\`moc\`)
697
+
698
+ * Performance: inline prim-wrapping functions (thanks to nomeata) (#3159)
699
+ * Improve type pretty printer to mirror type parser (avoids producing unparseable stable variable signatures) (#3190)
700
+ * Adds new flag \`--omit-metadata\` to omit certain metadata sections from \`actor\` (and \`actor class\`) Wasm (#3164)
701
+ * Performance: avoid redundant heap allocation when deserializing compact Candid \`int\` and \`nat\` values (#3173)
702
+ * Added a primitive to obtain stable variable memory footprint (#3049)
703
+
704
+ * motoko-base
705
+
706
+ * Fixed the 32-bit range limitation of \`Hash.hash: Nat -> Nat32\` and
707
+ deprecate most functions in \`Hash\` (dfinity/motoko-base#366).
708
+ * Add \`List.toIter\` (thanks to hoosan) (dfinity/motoko-base#336).
709
+
710
+ ## 0.6.25 (2022-03-07)
711
+
712
+ * motoko (\`moc\`)
713
+
714
+ * bugfix: fix bogus elision of type constructors sharing names with primitive types in \`--stable-types\` section and \`.most\` file (#3140)
715
+
716
+ ## 0.6.24 (2022-03-06)
717
+
718
+ * motoko (\`moc\`)
719
+
720
+ * bugfix: fix bogus identification of distinct type constructors
721
+ in --stable-types section and .most file (#3140)
722
+
723
+ ## 0.6.23 (2022-03-05)
724
+
725
+ * motoko (\`moc\`)
726
+
727
+ * bugfix: fix pretty printing of (stable) types and #3128 (#3130)
728
+
729
+ * Collect constructors *transitively* before emitting a .most file.
730
+ * Modifies type pretty printer to produce well-formed types and stable type signatures.
731
+
732
+ ## 0.6.22 (2022-02-24)
733
+
734
+ * motoko (\`moc\`)
735
+
736
+ * Fix: remove bogus error when transitively importing module with
737
+ selective field imports (#3121)
738
+ * Fix: Treating eponymous types from separate candid files (#3103)
739
+
740
+ * Various reports from CI are now pushed to
741
+ https://dfinity.github.io/motoko (#3113)
742
+
743
+ ## 0.6.21 (2022-01-31)
744
+
745
+ * motoko (\`moc\`)
746
+
747
+ * Emit new ICP metadata custom section 'motoko:compiler' with compiler release or revision in UTF8 (e.g. "0.6.21"). Default is \`icp:private\` (#3091).
748
+ * Generalized \`import\` supporting pattern matching and selective field imports (#3076).
749
+ * Fix: insert critical overflow checks preventing rare heap corruptions
750
+ in out-of-memory allocation and stable variable serialization (#3077).
751
+ * Implement support for 128-bit Cycles-API (#3042).
752
+
753
+ * motoko-base
754
+
755
+ * \`ExperimentalInternetComputer\` library, exposing low-level, binary \`call\` function (a.k.a. "raw calls") (dfinity/motoko-base#334, Motoko #3806).
756
+ * \`Principal.fromBlob\` added (dfinity/motoko-base#331).
757
+
758
+ ## 0.6.20 (2022-01-11)
759
+
760
+ * motoko
761
+
762
+ * Implement support for \`heartbeat\` system methods (thanks to ninegua) (#2971)
763
+
764
+ * motoko-base
765
+
766
+ * Add \`Iter.filter : <A>(Iter<A>, A -> Bool) -> Iter<A>\` (thanks to jzxchiang1) (dfinity/motoko-base#328).
767
+
768
+ ## 0.6.19 (2022-01-05)
769
+
770
+ * motoko-base
771
+
772
+ * Fixed a bug in the \`RBTree.size()\` method.
773
+
774
+ ## 0.6.18 (2021-12-20)
775
+
776
+ * moc
777
+
778
+ * Add runtime support for low-level, direct access to 64-bit IC stable memory, including documentation.
779
+ * Add compiler flag \`--max-stable-pages <n>\` to cap any use of \`ExperimentalStableMemory.mo\` (see below), while reserving space for stable variables.
780
+ Defaults to 65536 (4GiB).
781
+
782
+ * motoko-base
783
+
784
+ * (Officially) add \`ExperimentalStableMemory.mo\` library, exposing 64-bit IC stable memory
785
+
786
+ * BREAKING CHANGE (Minor):
787
+ The previously available (but unadvertised) \`ExperimentalStableMemory.mo\` used
788
+ \`Nat32\` offsets. This one uses \`Nat64\` offsets to (eventually) provide access to more address space.
789
+
790
+ ## 0.6.17 (2021-12-10)
791
+
792
+ * Improved handling of one-shot messages facilitating zero-downtime
793
+ upgrades (#2938).
794
+ * Further performance improvements to the mark-compact garbage
795
+ collector (#2952, #2973).
796
+ * Stable variable checking for \`moc.js\` (#2969).
797
+ * A bug was fixed in the scoping checker (#2977).
798
+
799
+ ## 0.6.16 (2021-12-03)
800
+
801
+ * Minor performance improvement to the mark-compact garbage collector
802
+
803
+
804
+ ## 0.6.15 (2021-11-26)
805
+
806
+ * Fixes crash when (ill-typed) \`switch\` expression on non-variant
807
+ value has variant alternatives (#2934)
808
+
809
+ ## 0.6.14 (2021-11-19)
810
+
811
+ * The compiler now embeds the existing Candid interface and new
812
+ _stable signature_ of a canister in additional Wasm custom sections,
813
+ to be selectively exposed by the IC, and to be used by tools such as \`dfx\`
814
+ to verify upgrade compatibility (see extended documentation).
815
+
816
+ New compiler options:
817
+
818
+ * \`--public-metadata <name>\`: emit ICP custom section \`<name>\` (\`candid:args\` or \`candid:service\` or \`motoko:stable-types\`) as \`public\` (default is \`private\`)
819
+ * \`--stable-types\`: emit signature of stable types to \`.most\` file
820
+ * \`--stable-compatible <pre> <post>\`: test upgrade compatibility between stable-type signatures \`<pre>\` and \`<post>\`
821
+
822
+ A Motoko canister upgrade is safe provided:
823
+
824
+ * the canister's Candid interface evolves to a Candid subtype; and
825
+ * the canister's Motoko stable signature evolves to a _stable-compatible_ one.
826
+
827
+ (Candid subtyping can be verified using tool \`didc\` available at:
828
+ https://github.com/dfinity/candid.)
829
+
830
+ * BREAKING CHANGE (Minor):
831
+ Tightened typing for type-annotated patterns (including function parameters)
832
+ to prevent some cases of unintended and counter-intuitive type propagation.
833
+
834
+ This may break some rare programs that were accidentally relying on that
835
+ propagation. For example, the indexing \`xs[i]\` in the following snippet
836
+ happend to type-check before, because \`i\` was given the more precise
837
+ type \`Nat\` (inferred from \`run\`'s parameter type), regardless of the
838
+ overly liberal declaration as an \`Int\`:
839
+
840
+ \`\`\`motoko
841
+ func run(f : Nat -> Text) {...};
842
+ let xs = ["a", "b", "c"];
843
+ run(func(i : Int) { xs[i] });
844
+ \`\`\`
845
+ This no longer works, \`i\` has to be declared as \`Nat\` (or the type omitted).
846
+
847
+ If you encounter such cases, please adjust the type annotation.
848
+
849
+ * Improved garbage collection scheduling
850
+
851
+ * Miscellaneous performance improvements
852
+ - code generation for \`for\`-loops over arrays has improved
853
+ - slightly sped up \`Int\` equality comparisons
854
+
855
+ ## 0.6.13 (2021-11-19)
856
+
857
+ *Pulled*
858
+
859
+ ## 0.6.12 (2021-10-22)
860
+
861
+ * \`for\` loops over arrays are now converted to more efficient
862
+ index-based iteration (#2831). This can result in significant cycle
863
+ savings for tight loops, as well as slightly less memory usage.
864
+
865
+ * Add type union and intersection. The type expression
866
+
867
+ \`\`\`motoko
868
+ T and U
869
+ \`\`\`
870
+ produces the greatest lower bound of types \`T\` and \`U\`, that is,
871
+ the greatest type that is a subtype of both. Dually,
872
+
873
+ \`\`\`motoko
874
+ T or U
875
+ \`\`\`
876
+ produces the least upper bound of types \`T\` and \`U\`, that is,
877
+ the smallest type that is a supertype of both.
878
+
879
+ One use case of the former is "extending" an existing object type:
880
+
881
+ \`\`\` motoko
882
+ type Person = {name : Text; address : Text};
883
+ type Manager = Person and {underlings : [Person]};
884
+ \`\`\`
885
+ Similarly, the latter can be used to "extend" a variant type:
886
+ \`\`\`motoko
887
+ type Workday = {#mon; #tue; #wed; #thu; #fri};
888
+ type Weekday = Workday or {#sat; #sun};
889
+ \`\`\`
890
+
891
+ ## 0.6.11 (2021-10-08)
892
+
893
+ * Assertion error messages are now reproducible (#2821)
894
+
895
+ ## 0.6.10 (2021-09-23)
896
+
897
+ * moc
898
+
899
+ * documentation changes
900
+
901
+ * motoko-base
902
+
903
+ * documentation changes
904
+
905
+ ## 0.6.9 (2021-09-15)
906
+
907
+ * motoko-base
908
+
909
+ * add Debug.trap : Text -> None (dfinity/motoko-base#288)
910
+
911
+ ## 0.6.8 (2021-09-06)
912
+
913
+ * Introduce primitives for \`Int\` ⇔ \`Float\` conversions (#2733)
914
+ * Bump LLVM toolchain to version 12 (#2542)
915
+ * Support extended name linker sections (#2760)
916
+ * Fix crashing bug for formatting huge floats (#2737)
917
+
918
+ ## 0.6.7 (2021-08-16)
919
+
920
+ * moc
921
+
922
+ * Optimize field access by exploiting field ordering (#2708)
923
+ * Fix handling of self references in mark-compact GC (#2721)
924
+ * Restore CI reporting of perf-regressions (#2643)
925
+
926
+ * motoko-base:
927
+
928
+ * Fix bug in \`AssocList.diff\` (dfinity/motoko-base#277)
929
+ * Deprecate unsafe or redundant functions in library \`Option\` ( \`unwrap\`, \`assertSome\`, \`assertNull\`) (#275)
930
+
931
+ ## 0.6.6 (2021-07-30)
932
+
933
+ * Vastly improved garbage collection scheduling: previously Motoko runtime would do GC
934
+ after every update message. We now schedule a GC when
935
+
936
+ 1. Heap grows more than 50% and 10 MiB since the last GC, or
937
+ 2. Heap size is more than 3 GiB
938
+
939
+ (1) is to make sure we don't do GC on tiny heaps or after only small amounts of allocation.
940
+ (2) is to make sure that on large heaps we will have enough allocation space during the next message.
941
+
942
+ This scheduling reduces cycles substantially, but may moderately increase memory usage.
943
+
944
+ New flag \`--force-gc\` restores the old behavior.
945
+
946
+ * Fix bug in compacting gc causing unnecessary memory growth (#2673)
947
+
948
+ * Trap on attempt to upgrade when canister not stopped and there are outstanding callbacks.
949
+ (This failure mode can be avoided by stopping the canister before upgrade.)
950
+
951
+ * Fix issue #2640 (leaked \`ClosureTable\` entry when awaiting futures fails).
952
+
953
+ ## 0.6.5 (2021-07-08)
954
+
955
+ * Add alternative, _compacting_ gc, enabled with new moc flag \`--compacting-gc\`.
956
+ The compacting gc supports larger heap sizes than the default, 2-space copying collector.
957
+
958
+ NOTE: Dfx 0.7.6 adds optional field \`"args"\` to \`dfx.json\` files,
959
+ so Motoko canisters can specify \`moc\` command-line arguments. E.g.,
960
+
961
+ \`\`\`json
962
+ ...
963
+ "type" : "motoko"
964
+ ...
965
+ "args" : "--compacting-gc"
966
+ ...
967
+ \`\`\`
968
+
969
+ * Documentation fixes.
970
+ * Command line tools: \`--help\` option provides better documentation of command line
971
+ options that have arguments.
972
+ * Fix issue #2319 (crash on import of Candid class).
973
+
974
+ ## 0.6.4 (2021-06-12)
975
+
976
+ * For release builds, the banner (\`moc --version\`) now includes the release
977
+ version.
978
+
979
+ * Fix MacOS release builds (the 0.6.3 tarball for MacOS contained the linux binaries)
980
+
981
+ ## 0.6.3 (2021-06-10)
982
+
983
+ * Motoko is now open source!
984
+
985
+ * Better internal consistency checking of the intermediate representation
986
+
987
+ ## 0.6.2 (2021-05-24)
988
+
989
+ * motoko-base:
990
+
991
+ * reformat to style guidelines
992
+ * add type bindings \`Nat.Nat\`, \`Nat8.Nat8\` etc. to libraries for primitive types.
993
+
994
+ * Bugfix: generation of candid from Motoko:
995
+
996
+ * no longer confused by distinct, but eponymous, type definitions (Bug: #2529);
997
+ * numbers eponymous types and specializations from 1 (not 2);
998
+ * avoids long chains of type equalities by normalizing before translation.
999
+
1000
+ ## 0.6.1 (2021-04-30)
1001
+
1002
+ * Internal: Update to IC interface spec 0.17 (adapt to breaking change to signature of \`create_canister\`)
1003
+
1004
+ ## 0.6.0 (2021-04-16)
1005
+
1006
+ * BREAKING CHANGE:
1007
+ The old-style object and block syntax deprecated in 0.5.0 is finally removed.
1008
+
1009
+ * Record punning: As already supported in patterns, short object syntax in
1010
+ expressions now allows omitting the right-hand side if it is an identifier
1011
+ of the same name as the label. That is,
1012
+
1013
+ \`\`\`motoko
1014
+ {a; b = 1; var c}
1015
+ \`\`\`
1016
+
1017
+ is short for
1018
+
1019
+ \`\`\`motoko
1020
+ {a = a; b = 1; var c = c}
1021
+ \`\`\`
1022
+
1023
+ assuming respective variables are in scope.
1024
+
1025
+ * BREAKING CHANGE:
1026
+ The types \`Word8\`, \`Word16\`, \`Word32\` and \`Word64\` have been removed.
1027
+ This also removed the \`blob.bytes()\` iterator.
1028
+
1029
+ Motoko base also dropped the \`Word8\`, \`Word16\`, \`Word32\` and \`Word64\`
1030
+ modules.
1031
+
1032
+ This concludes the transition to the other fixed-width types that began with
1033
+ version 0.5.8
1034
+
1035
+ * BREAKING CHANGE (Minor):
1036
+ \`await\` on a completed future now also commits state and suspends
1037
+ computation, to ensure every await, regardless of its future's state,
1038
+ is a commit point for state changes and tentative message sends.
1039
+
1040
+ (Previously, only awaits on pending futures would force a commit
1041
+ and suspend, while awaits on completed futures would continue
1042
+ execution without an incremental commit, trading safety for speed.)
1043
+
1044
+ * motoko-base: fixed bug in \`Text.compareWith\`.
1045
+
1046
+ ## 0.5.15 (2021-04-13)
1047
+
1048
+ * Bugfix: \`Blob.toArray\` was broken.
1049
+
1050
+ ## 0.5.14 (2021-04-09)
1051
+
1052
+ * BREAKING CHANGE (Minor): Type parameter inference will no longer default
1053
+ under-constrained type parameters that are invariant in the result, but
1054
+ require an explicit type argument.
1055
+ This is to avoid confusing the user by inferring non-principal types.
1056
+
1057
+ For example, given (invariant) class \`Box<A>\`:
1058
+
1059
+ \`\`\`motoko
1060
+ class Box<A>(a : A) { public var value = a; };
1061
+ \`\`\`
1062
+
1063
+ the code
1064
+
1065
+ \`\`\`motoko
1066
+ let box = Box(0); // rejected
1067
+ \`\`\`
1068
+
1069
+ is rejected as ambiguous and requires an instantiation, type annotation or
1070
+ expected type. For example:
1071
+
1072
+ \`\`\`motoko
1073
+ let box1 = Box<Int>(0); // accepted
1074
+ let box2 : Box<Nat> = Box(0); // accepted
1075
+ \`\`\`
1076
+
1077
+ Note that types \`Box<Int>\` and \`Box<Nat>\` are unrelated by subtyping,
1078
+ so neither is best (or principal) in the ambiguous, rejected case.
1079
+
1080
+ * Bugfix: Type components in objects/actors/modules correctly ignored
1081
+ when involved in serialization, equality and \`debug_show\`, preventing
1082
+ the compiler from crashing.
1083
+
1084
+ * motoko-base: The \`Text.hash\` function was changed to a better one.
1085
+ If you stored hashes as stable values (which you really shouldn't!)
1086
+ you must rehash after upgrading.
1087
+
1088
+ * motoko-base: Conversion functions between \`Blob\` and \`[Nat8]\` are provided.
1089
+
1090
+ * When the compiler itself crashes, it will now ask the user to report the
1091
+ backtrace at the DFINITY forum
1092
+
1093
+ ## 0.5.13 (2021-03-25)
1094
+
1095
+ * The \`moc\` interpreter now pretty-prints values (as well as types) in the
1096
+ repl, producing more readable output for larger values.
1097
+
1098
+ * The family of \`Word\` types are deprecated, and mentioning them produces a warning.
1099
+ These type will be removed completely in a subsequent release.
1100
+ See the user’s guide, section “Word types”, for a migration guide.
1101
+
1102
+ * motoko base: because of this deprecation, the \`Char.from/toWord32()\`
1103
+ functions are removed. Migrate away from \`Word\` types, or use
1104
+ \`Word32.from/ToChar\` for now.
1105
+
1106
+ ## 0.5.12 (2021-03-23)
1107
+
1108
+ * The \`moc\` compiler now pretty-prints types in error messages and the repl,
1109
+ producing more readable output for larger types.
1110
+
1111
+ * motoko base: fixed bug in \`Text.mo\` affecting partial matches in,
1112
+ for example, \`Text.replace\` (GH issue #234).
1113
+
1114
+ ## 0.5.11 (2021-03-12)
1115
+
1116
+ * The \`moc\` compiler no longer rejects occurrences of private or
1117
+ local type definitions in public interfaces.
1118
+
1119
+ For example,
1120
+
1121
+ \`\`\`motoko
1122
+ module {
1123
+ type List = ?(Nat, List); // private
1124
+ public func cons(n : Nat, l : List) : List { ?(n , l) };
1125
+ }
1126
+ \`\`\`
1127
+
1128
+ is now accepted, despite \`List\` being private and appearing in the type
1129
+ of public member \`cons\`.
1130
+
1131
+ * Type propagation for binary operators has been improved. If the type of one of
1132
+ the operands can be determined locally, then the other operand is checked
1133
+ against that expected type. This should help avoiding tedious type annotations
1134
+ in many cases of literals, e.g., \`x == 0\` or \`2 * x\`, when \`x\` has a special
1135
+ type like \`Nat8\`.
1136
+
1137
+ * The \`moc\` compiler now rejects type definitions that are non-_productive_ (to ensure termination).
1138
+
1139
+ For example, problematic types such as:
1140
+
1141
+ \`\`\`motoko
1142
+ type C = C;
1143
+ type D<T, U> = D<U, T>;
1144
+ type E<T> = F<T>;
1145
+ type F<T> = E<T>;
1146
+ type G<T> = Fst<G<T>, Any>;
1147
+ \`\`\`
1148
+
1149
+ are now rejected.
1150
+
1151
+ * motoko base: \`Text\` now contains \`decodeUtf8\` and \`encodeUtf8\`.
1152
+
1153
+ ## 0.5.10 (2021-03-02)
1154
+
1155
+ * User defined deprecations
1156
+
1157
+ Declarations in modules can now be annotated with a deprecation comment, which make the compiler emit warnings on usage.
1158
+
1159
+ This lets library authors warn about future breaking changes:
1160
+
1161
+ As an example:
1162
+
1163
+ \`\`\`motoko
1164
+ module {
1165
+ /// @deprecated Use \`bar\` instead
1166
+ public func foo() {}
1167
+
1168
+ public func bar() {}
1169
+ }
1170
+ \`\`\`
1171
+
1172
+ will emit a warning whenever \`foo\` is used.
1173
+
1174
+ * The \`moc\` compiler now rejects type definitions that are _expansive_, to help ensure termination.
1175
+ For example, problematic types such as \`type Seq<T> = ?(T, Seq<[T]>)\` are rejected.
1176
+
1177
+ * motoko base: \`Time.Time\` is now public
1178
+
1179
+ ## 0.5.9 (2021-02-19)
1180
+
1181
+ * The \`moc\` compiler now accepts the \`-Werror\` flag to turn warnings into errors.
1182
+
1183
+ * The language server now returns documentation comments alongside
1184
+ completions and hover notifications
1185
+
1186
+ ## 0.5.8 (2021-02-12)
1187
+
1188
+ * Wrapping arithmetic and bit-wise operations on \`NatN\` and \`IntN\`
1189
+
1190
+ The conventional arithmetic operators on \`NatN\` and \`IntN\` trap on overflow.
1191
+ If wrap-around semantics is desired, the operators \`+%\`, \`-%\`, \`*%\` and \`**%\`
1192
+ can be used. The corresponding assignment operators (\`+%=\` etc.) are also available.
1193
+
1194
+ Likewise, the bit fiddling operators (\`&\`, \`|\`, \`^\`, \`<<\`, \`>>\`, \`<<>\`,
1195
+ \`<>>\` etc.) are now also available on \`NatN\` and \`IntN\`. The right shift
1196
+ operator (\`>>\`) is an unsigned right shift on \`NatN\` and a signed right shift
1197
+ on \`IntN\`; the \`+>>\` operator is _not_ available on these types.
1198
+
1199
+ The motivation for this change is to eventually deprecate and remove the
1200
+ \`WordN\` types.
1201
+
1202
+ Therefore, the wrapping arithmetic operations on \`WordN\` are deprecated and
1203
+ their use will print a warning. See the user’s guide, section “Word types”,
1204
+ for a migration guide.
1205
+
1206
+ * For values \`x\` of type \`Blob\`, an iterator over the elements of the blob
1207
+ \`x.vals()\` is introduced. It works like \`x.bytes()\`, but returns the elements
1208
+ as type \`Nat8\`.
1209
+
1210
+ * \`mo-doc\` now generates cross-references for types in signatures in
1211
+ both the Html as well as the Asciidoc output. So a signature like
1212
+ \`fromIter : I.Iter<Nat> -> List.List<Nat>\` will now let you click on
1213
+ \`I.Iter\` or \`List.List\` and take you to their definitions.
1214
+
1215
+ * Bugfix: Certain ill-typed object literals are now prevented by the type
1216
+ checker.
1217
+
1218
+ * Bugfix: Avoid compiler aborting when object literals have more fields than
1219
+ their type expects.
1220
+
1221
+ ## 0.5.7 (2021-02-05)
1222
+
1223
+ * The type checker now exploits the expected type, if any,
1224
+ when typing object literal expressions.
1225
+ So \`{ x = 0 } : { x : Nat8 }\` now works as expected
1226
+ instead of requiring an additional type annotation on \`0\`.
1227
+
1228
+ ## 0.5.6 (2021-01-22)
1229
+
1230
+ * The compiler now reports errors and warnings with an additional _error code_
1231
+ This code can be used to look up a more detailed description for a given error by passing the \`--explain\` flag with a code to the compiler.
1232
+ As of now this isn't going to work for most codes because the detailed descriptions still have to be written.
1233
+ * Internal: The parts of the RTS that were written in C have been ported to Rust.
1234
+
1235
+ ## 0.5.5 (2021-01-15)
1236
+
1237
+ * new \`moc\` command-line arguments \`--args <file>\` and \`--args0 <file>\` for
1238
+ reading newline/NUL terminated arguments from \`<file>\`.
1239
+ * motoko base: documentation examples are executable in the browser
1240
+
1241
+ ## 0.5.4 (2021-01-07)
1242
+
1243
+ * _Option blocks_ \`do ? <block>\` and _option checks_ \`<exp> !\`.
1244
+ Inside an option block, an option check validates that its operand expression is not \`null\`.
1245
+ If it is, the entire option block is aborted and evaluates to \`null\`.
1246
+ This simplifies consecutive null handling by avoiding verbose \`switch\` expressions.
1247
+
1248
+ For example, the expression \`do? { f(x!, y!) + z!.a }\` evaluates to \`null\` if either \`x\`, \`y\` or \`z\` is \`null\`;
1249
+ otherwise, it takes the options' contents and ultimately returns \`?r\`, where \`r\` is the result of the addition.
1250
+
1251
+ * BREAKING CHANGE (Minor):
1252
+ The light-weight \`do <exp>\` form of the recently added, more general \`do <block-or-exp>\` form,
1253
+ is no longer legal syntax.
1254
+ That is, the argument to a \`do\` or \`do ?\` expression *must* be a block \`{ ... }\`,
1255
+ never a simple expression.
1256
+
1257
+ ## 0.5.3 (2020-12-10)
1258
+
1259
+ * Nothing new, just release moc.js to CDN
1260
+
1261
+ ## 0.5.2 (2020-12-04)
1262
+
1263
+ * Bugfix: gracefully handle importing ill-typed actor classes
1264
+
1265
+ ## 0.5.1 (2020-11-27)
1266
+
1267
+ * BREAKING CHANGE: Simple object literals of the form \`{a = foo(); b = bar()}\`
1268
+ no longer bind the field names locally. This enables writing expressions
1269
+ like \`func foo(a : Nat) { return {x = x} }\`.
1270
+
1271
+ However, this breaks expressions like \`{a = 1; b = a + 1}\`. Such object
1272
+ shorthands now have to be written differently, e.g., with an auxiliary
1273
+ declaration, as in \`let a = 1; {a = a; b = a + 1}\`, or by using the "long"
1274
+ object syntax \`object {public let a = 1; public let b = a + 1}\`.
1275
+
1276
+ ## 0.5.0 (2020-11-27)
1277
+
1278
+ * BREAKING CHANGE: Free-standing blocks are disallowed
1279
+
1280
+ Blocks are only allowed as sub-expressions of control flow expressions like
1281
+ \`if\`, \`loop\`, \`case\`, etc. In all other places, braces are always considered
1282
+ to start an object literal.
1283
+
1284
+ To use blocks in other positions, the new \`do <block>\` expression can be
1285
+ used.
1286
+
1287
+ The more liberal syntax is still allowed for now but deprecated, i.e.,
1288
+ produces a warning.
1289
+
1290
+ * BREAKING CHANGE: actor creation is regarded as asynchronous:
1291
+
1292
+ * Actor declarations are asynchronous and can only be used in asynchronous
1293
+ contexts.
1294
+ * The return type of an actor class, if specified, must be an async actor
1295
+ type.
1296
+ * To support actor declaration, the top-level context of an interpreted
1297
+ program is an asynchronous context, allowing implicit and explicit await
1298
+ expressions.
1299
+
1300
+ (Though breaking, this change mostly affects interpreted programs and
1301
+ compiled programs with explicate actor class return types)
1302
+
1303
+ * Candid support is updated to latest changes of the Candid spec, in particular
1304
+ the ability to extend function with optional parameters in a backward
1305
+ compatible way.
1306
+
1307
+ Motoko passes the official Candid compliance test suite.
1308
+
1309
+ * RTS: Injecting a value into an option type (\`? <exp>\`) no longer
1310
+ requires heap allocation in most cases. This removes the memory-tax
1311
+ of using iterators.
1312
+
1313
+ * Bugfix: Passing cycles to the instantiation of an actor class works now.
1314
+
1315
+ * Various bug fixes and documentation improvements.
1316
+
1317
+ ## 0.4.6 (2020-11-13)
1318
+
1319
+ * Significant documentation improvements
1320
+ * Various bugfixes
1321
+ * Improved error messages
1322
+ * Initial DWARF support
1323
+ * Candid compliance improvements:
1324
+ * Strict checking of utf8 strings
1325
+ * More liberal parsing of leb128-encoded numbers
1326
+ * New motoko-base:
1327
+ * The Random library is added
1328
+
1329
+ ## 0.4.5 (2020-10-06)
1330
+
1331
+ * BREAKING CHANGE: a library containing a single actor class is
1332
+ imported as a module, providing access to both the class type and
1333
+ class constructor function as module components. Restores the
1334
+ invariant that imported libraries are modules.
1335
+ * Backend: Compile captured actor class parameters statically (#2022)
1336
+ * flip the default for -g (#1546)
1337
+ * Bug fix: reject array indexing as non-static (could trap) (#2011)
1338
+ * Initialize tuple length fields (#1992)
1339
+ * Warns for structural equality on abstract types (#1972)
1340
+ * Funds Imperative API (#1922)
1341
+ * Restrict subtyping (#1970)
1342
+ * Continue labels always have unit codomain (#1975)
1343
+ * Compile.ml: target and use new builder call pattern (#1974)
1344
+ * fix scope var bugs (#1973)
1345
+
1346
+ ## 0.4.4 (2020-09-21)
1347
+
1348
+ * Actor class export
1349
+ * Accept unit installation args for actors
1350
+ * Reject platform actor (class) programs with additional decs
1351
+ * Handle IO exceptions at the top-level
1352
+ * RTS: Remove duplicate array and blob allocation code
1353
+ * RTS: Fix pointer arithmetic in BigInt collection function
1354
+
1355
+ ## 0.4.3 (2020-09-14)
1356
+
1357
+ * Preliminary support for actor class import and dynamic canister installation.
1358
+ Surface syntax may change in future.
1359
+ * BREAKING CHANGE: a compilation unit/file defining an actor or actor class may *only* have leading \`import\` declarations; other leading declarations (e.g. \`let\` or \`type\`) are no longer supported.
1360
+ * Rust GC
1361
+
1362
+ ## 0.4.2 (2020-08-18)
1363
+
1364
+ * Polymorphic equality. \`==\` and \`!=\` now work on all shareable types.
1365
+
1366
+ ## 0.4.1 (2020-08-13)
1367
+
1368
+ * Switching to bumping the third component of the version number
1369
+ * Bugfix: clashing declarations via function and class caught (#1756)
1370
+ * Bugfix: Candid \`bool\` decoding rejects invalid input (#1783)
1371
+ * Canisters can take installation arguments (#1809)
1372
+ NB: Communicating the type of the canister installation methods is still
1373
+ missing.
1374
+ * Optimization: Handling of \`Bool\` in the backend.
1375
+
1376
+ ## 0.4 (2020-08-03)
1377
+
1378
+ * Candid pretty printer to use shorthand when possible (#1774)
1379
+ * fix candid import to use the new id format (#1787)
1380
+
1381
+ ## 0.3 (2020-07-31)
1382
+
1383
+ * Fixes an issue with boolean encoding to Candid
1384
+ * Converts the style guide to asciidocs
1385
+
1386
+ ## 0.2 (2020-07-30)
1387
+
1388
+ * The \`Blob\` type round-trips through candid type export/import (#1744)
1389
+ * Allow actor classes to know the caller of their constructor (#1737)
1390
+ * Internals: \`Prim.time()\` provided (#1747)
1391
+ * Performance: More dead code removal (#1752)
1392
+ * Performance: More efficient arithmetic with unboxed values (#1693, #1757)
1393
+ * Canister references are now parsed and printed according to the new
1394
+ base32-based textual format (#1732).
1395
+ * The runtime is now embedded into \`moc\` and need not be distributed separately
1396
+ (#1772)
1397
+
1398
+ ## 0.1 (2020-07-20)
1399
+
1400
+ * Beginning of the changelog. Released with dfx-0.6.0.
1401
+
1402
+ 0.111 (2020-07-20)
1403
+ =========
1404
+
1405
+ 0.22222
1406
+ ----
1407
+
1408
+ * Beginning of the changelog. Released with dfx-0.6.0.
1409
+ `;
1410
+ console.log(markdownHeadings(''));
1411
+ console.log(markdownHeadings(str).find((x) => x.match(new RegExp('\\b0.6.13\\b'))));