0.12.0
-
motoko (
moc)-
feat:
finallyclauses fortryexpressions (#4507).A trailing
finallyclause totry/catchexpressions 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 offinallythecatchclause becomes optional and
and any uncaught error from thetryblock will be propagated, after executing thefinallyblock.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):
finallyis now a reserved keyword,
programs using this identifier will break. -
bugfix:
mo-docwill now generate correct entries forpublicvariables (#4626).
-