0.12.0
-
motoko (
moc
)-
feat:
finally
clauses fortry
expressions (#4507).A trailing
finally
clause totry
/catch
expressions facilitates structured
resource deallocation (e.g. acquired locks, etc.) and similar cleanups in the
presence of control-flow expressions (return
,break
,continue
,throw
).
Additionally, in presence offinally
thecatch
clause becomes optional and
and any uncaught error from thetry
block will be propagated, after executing thefinally
block.Note:
finally
-expressions that are in scope will be executed even if an execution
path following anawait
-expression traps. This feature, formerly not available in Motoko,
allows programmers to implement cleanups even in the presence of traps. For trapping
execution paths prior to anyawait
, the replica-provided state roll-back mechanism
ensures that no cleanup is required.The relevant security best practices are accessible at
https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/inter-canister-calls#recommendationBREAKING CHANGE (Minor):
finally
is now a reserved keyword,
programs using this identifier will break. -
bugfix:
mo-doc
will now generate correct entries forpublic
variables (#4626).
-