1"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[989],{68340:(s,e,n)=>{n.r(e),n.d(e,{assets:()=>d,contentTitle:()=>a,default:()=>t,frontMatter:()=>c,metadata:()=>i,toc:()=>o});var i=n(21274),r=n(13274),l=n(98703);const c={},a="20260819 MoonBit v0.10.9 Release",d={authorsImageUrls:[]},o=[{value:"Language Updates",id:"language-updates",level:2},{value:"Toolchain Updates",id:"toolchain-updates",level:2},{value:"Standard Library Updates",id:"standard-library-updates",level:2}];function h(s){const e={a:"a",code:"code",h2:"h2",hr:"hr",li:"li",ol:"ol",p:"p",pre:"pre",span:"span",strong:"strong",ul:"ul",...(0,l.R)(),...s.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"moonc version:"})," ",(0,r.jsx)(e.code,{children:"v0.10.9"})]}),"\n",(0,r.jsx)(e.h2,{id:"language-updates",children:"Language Updates"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"with"}),"-patterns now require explicit parentheses around branches that use ",(0,r.jsx)(e.code,{children:"with"}),", making the precedence of ",(0,r.jsx)(e.code,{children:"with"}),"-patterns easier for readers to understand. Users can migrate automatically with ",(0,r.jsx)(e.code,{children:"moon fmt"}),":"]}),"\n",(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(e.pre,{className:"shiki shiki-themes one-light one-dark-pro",style:{backgroundColor:"#FAFAFA","--shiki-dark-bg":"#282c34",color:"#383A42","--shiki-dark":"#abb2bf"},tabIndex:"0",children:(0,r.jsxs)(e.code,{children:[(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:"fn"}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" main"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" {"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" let"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" a"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#56B6C2"},children:" ="}),(0,r.jsx)(e.span,{style:{color:"#C18401","--shiki-dark":"#E5C07B"},children:" Some"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:'"hello"'}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:")"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" match"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" a"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" {"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#C18401","--shiki-dark":"#E5C07B"},children:" Some"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"x"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:") "}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#56B6C2"},children:"|"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" ("}),(0,r.jsx)(e.span,{style:{color:"#C18401","--shiki-dark":"#E5C07B"},children:"None"}),(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" with"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" x"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#56B6C2"},children:" ="}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:' ""'}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:") "}),(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:"=>"}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" println"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"x"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:")"})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#A0A1A7",fontStyle:"italic","--shiki-dark":"#7F848E","--shiki-dark-font-style":"italic"},children:" // ^~~~~~~~~~~~~~~~~~ parentheses required here"})}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" }"})}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"}"})})]})})}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["Bitstring patterns now support ",(0,r.jsx)(e.code,{children:"v128le"}),", which extracts 16 bytes at once from a byte sequence and constructs a ",(0,r.jsx)(e.code,{children:"V128"})," value. Currently only byte-granularity little-endian extraction is supported, i.e. byte 0 of the input maps to the least significant byte of the result:"]}),"\n",(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(e.pre,{className:"shiki shiki-themes one-light one-dark-pro",style:{backgroundColor:"#FAFAFA","--shiki-dark-bg":"#282c34",color:"#383A42","--shiki-dark":"#abb2bf"},tabIndex:"0",children:(0,r.jsxs)(e.code,{children:[(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:"fn"}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" main"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" {"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" let"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" bits"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#56B6C2"},children:" ="}),(0,r.jsx)(e.span,{style:{color:"#C18401","--shiki-dark":"#E5C07B"},children:" Bytes"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"::"}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"}
1,children:"makei"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#986801","--shiki-dark":"#D19A66"},children:"16"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:", "}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"i"}),(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" =>"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" i"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"."}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:"to_byte"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"())"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" guard"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"! "}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"bits"}),(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" is"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" ["}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:"v128le"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"bits"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"), ..]"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" println"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"bits"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:") "}),(0,r.jsx)(e.span,{style:{color:"#A0A1A7",fontStyle:"italic","--shiki-dark":"#7F848E","--shiki-dark-font-style":"italic"},children:"// prints V128(0x0706050403020100, 0x0f0e0d0c0b0a0908)"})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"}"})})]})})}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"lexscan"})," is now officially stable."]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"lexscan"})," supports ",(0,r.jsx)(e.code,{children:"@lexbuf.Lexbuf"}),", ",(0,r.jsx)(e.code,{children:"@lexbuf.AsyncLexbuf"}),", and ",(0,r.jsx)(e.code,{children:"@lexbuf.StringScanner"}),". ",(0,r.jsx)(e.code,{children:"Lexbuf"})," and ",(0,r.jsx)(e.code,{children:"AsyncLexbuf"})," operate in streaming mode; we have optimized their memory usage, so you can safely use them on infinite streams."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["The previous ",(0,r.jsx)(e.code,{children:"lexscan"})," on ",(0,r.jsx)(e.code,{children:"String/StringView"})," has been migrated to the ",(0,r.jsx)(e.code,{children:"lexmatch"})," keyword."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:"A catch-all case is no longer required when it is provably unreachable, and the compiler now reports warnings for unreachable cases."}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(e.pre,{className:"shiki shiki-themes one-light one-dark-pro",style:{backgroundColor:"#FAFAFA","--shiki-dark-bg":"#282c34",color:"#383A42","--shiki-dark":"#abb2bf"},tabIndex:"0",children:(0,r.jsxs)(e.code,{children:[(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#A0A1A7",fontStyle:"italic","--shiki-dark":"#7F848E","--shiki-dark-font-style":"italic"},children:"///|"})}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:"async"}),(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" fn"}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" wordcount"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" input"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" : "}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#E5C07B"},children:"@lexbuf"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"."}),(0,r.jsx)(e.span,{style:{color:"#C18401","--shiki-dark":"#E5C07B"},children:"AsyncLexbuf"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:","})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" lines"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" : "}),(0,r.jsx)(e.span,{style:{color:"#C18401","--shiki-dark":"#E5C07B"},children:"Int"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:","})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" words"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" : "}),(0,r.jsx)(e.span,{style:{color:"#C18401","--shiki-dark":"#E5C07B"},children:"Int"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:","})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" chars"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" : "}),(0,r.jsx)(e.span,{style:{color:"#C18401","--shiki-dark":"#E5C07B"},children:"Int"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:","})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:") "}),(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:"->"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" ("}),(0,r.jsx)(e.span,{style:{color:"#C18401","--shiki-dark":"#E5C07B"},children:"Int"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:", "}),(0,r.jsx)(e.span,{style:{color:"#C18401","--shiki-dark":"#E5C07B"},children:"Int"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:", "}),(0,r.jsx)(e.span,{style:{color:"#C18401","--shiki-dark":"#E5C07B"},children:"Int"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:") {"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" lexscan"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" input"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" {"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" re"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:'"^'}),(0,r.jsx)(e.span,{style:{color:"#0184BC","--shiki-dark":"#56B6C2"},children:"\\n"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:'"'}),(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" =>"}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" wordcount"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"input"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:", "}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"lines"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" + "}),(0,r.jsx)(e.span,{style:{color:"#986801","--shiki-dark":"#D19A66"},children:"1"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:", "}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"words"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:", "}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"chars"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" + "}),(0,r.jsx)(e.span,{style:{color:"#986801","--shiki-dark":"#D19A66"},children:"1"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:")"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" re"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:'"^[^ '}),(0,r.jsx)(e.span,{style:{color:"#0184BC","--shiki-dark":"#56B6C2"},children:"\\t\\r\\n"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:']+"'}),(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" as"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" word"}),(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" =>"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" wordcount"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"input"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:", "}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"lines"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:", "}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"words"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" + "}),(0,r.jsx)(e.span,{style:{color:"#986801","--shiki-dark":"#D19A66"},children:"1"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:", "}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"chars"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" + "}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"word"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"."}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:"length"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"}
1,children:"())"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" re"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:'"^."'}),(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" =>"}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" wordcount"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"input"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:", "}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"lines"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:", "}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"words"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:", "}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"chars"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" + "}),(0,r.jsx)(e.span,{style:{color:"#986801","--shiki-dark":"#D19A66"},children:"1"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:")"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" re"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:'"^"'}),(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" =>"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" ("}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"lines"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:", "}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"words"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:", "}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"chars"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:")"})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" }"})}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"}"})}),"\n",(0,r.jsx)(e.span,{className:"line"}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#A0A1A7",fontStyle:"italic","--shiki-dark":"#7F848E","--shiki-dark-font-style":"italic"},children:"///|"})}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:"async"}),(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" fn"}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" main"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" {"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" let"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" utf8_reader"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#56B6C2"},children:" ="}),(0,r.jsx)(e.span,{style:{color:"#C18401","--shiki-dark":"#E5C07B"},children:" Utf8Reader"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"(() "}),(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:"=>"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#E5C07B"},children:" @stdio"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:".stdin."}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:"read_some"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"())"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" let"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" lexbuf"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#56B6C2"},children:" ="}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#E5C07B"},children:" @lexbuf"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"."}),(0,r.jsx)(e.span,{style:{color:"#C18401","--shiki-dark":"#E5C07B"},children:"AsyncLexbuf"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"::"}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:"from_fn"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"(() "}),(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:"=>"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" utf8_reader"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"."}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:"read"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"}
1,children:"())"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" let"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" ("}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"lines"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:", "}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"words"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:", "}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"chars"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:") "}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#56B6C2"},children:"="}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" wordcount"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"lexbuf"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:", "}),(0,r.jsx)(e.span,{style:{color:"#986801","--shiki-dark":"#D19A66"},children:"0"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:", "}),(0,r.jsx)(e.span,{style:{color:"#986801","--shiki-dark":"#D19A66"},children:"0"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:", "}),(0,r.jsx)(e.span,{style:{color:"#986801","--shiki-dark":"#D19A66"},children:"0"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:")"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" println"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:'"lines: '}),(0,r.jsx)(e.span,{style:{color:"#CA1243","--shiki-dark":"#C678DD"},children:"\\{"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"lines"}),(0,r.jsx)(e.span,{style:{color:"#CA1243","--shiki-dark":"#C678DD"},children:"}"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:", words: "}),(0,r.jsx)(e.span,{style:{color:"#CA1243","--shiki-dark":"#C678DD"},children:"\\{"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"words"}),(0,r.jsx)(e.span,{style:{color:"#CA1243","--shiki-dark":"#C678DD"},children:"}"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:", chars: "}),(0,r.jsx)(e.span,{style:{color:"#CA1243","--shiki-dark":"#C678DD"},children:"\\{"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"chars"}),(0,r.jsx)(e.span,{style:{color:"#CA1243","--shiki-dark":"#C678DD"},children:"}"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:'"'}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:")"})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"}"})})]})})}),"\n",(0,r.jsx)(e.p,{children:"For details, see the documentation:"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://docs.moonbitlang.com/en/latest/language/fundamentals.html#lexmatch",children:"https://docs.moonbitlang.com/en/latest/language/fundamentals.html#lexmatch"})}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://docs.moonbitlang.com/en/latest/language/fundamentals.html#lexscan",children:"https://docs.moonbitlang.com/en/latest/language/fundamentals.html#lexscan"})}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["Introduced the new ",(0,r.jsx)(e.code,{children:"errdefer"})," syntax:"]}),"\n",(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(e.pre,{className:"shiki shiki-themes one-light one-dark-pro",style:{backgroundColor:"#FAFAFA","--shiki-dark-bg":"#282c34",color:"#383A42","--shiki-dark":"#abb2bf"},tabIndex:"0",children:(0,r.jsxs)(e.code,{children:[(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{children:"errdefer expr"})}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{children:"rest"})})]})})}),"\n",(0,r.jsxs)(e.p,{children:["If ",(0,r.jsx)(e.code,{children:"rest"})," raises an error, or is cancelled while running async code, the ",(0,r.jsx)(e.code,{children:"errdefer"})," statement will be triggered, executing ",(0,r.jsx)(e.code,{children:"expr"}),". The error will then be re-raised. ",(0,r.jsx)(e.code,{children:"errdefer"})," is especially useful for constructor-style functions, for example:"]}),"\n",(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(e.pre,{className:"shiki shiki-themes one-light one-dark-pro",style:{backgroundColor:"#FAFAFA","--shiki-dark-bg":"#282c34",color:"#383A42","--shiki-dark":"#abb2bf"},tabIndex:"0",children:(0,r.jsxs)(e.code,{children:[(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:"async"}),(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" fn"}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" connect_to"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"addr"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" : "}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#E5C07B"},children:"@socket"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"."}),(0,r.jsx)(e.span,{style:{color:"#C18401","--shiki-dark":"#E5C07B"},children:"Addr"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:") "}),(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:"->"}),(0,r.jsx)(e.span,{style:{color:"#C18401","--shiki-dark":"#E5C07B"},children:" Tcp"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" {"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" let"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" socket"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#56B6C2"},children:" ="}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" make_tcp_socket"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"}
1,children:"()"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" errdefer"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" socket"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"."}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:"close"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"()"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" connect_socket"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"socket"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:")"})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" socket"})}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"}"})})]})})}),"\n",(0,r.jsxs)(e.p,{children:["Here, if ",(0,r.jsx)(e.code,{children:"connect_to"})," returns normally, ownership of ",(0,r.jsx)(e.code,{children:"socket"})," is transferred to the caller through the return value, so ",(0,r.jsx)(e.code,{children:"socket"})," should not be released. But if ",(0,r.jsx)(e.code,{children:"connect_socket(socket)"})," raises an error or is cancelled, ",(0,r.jsx)(e.code,{children:"socket"})," will not be returned. In this case, ",(0,r.jsx)(e.code,{children:"socket"})," should be released to avoid a resource leak. ",(0,r.jsx)(e.code,{children:"errdefer"})," handles this kind of resource cleanup robustly."]}),"\n",(0,r.jsxs)(e.p,{children:["Leaving the scope of an ",(0,r.jsx)(e.code,{children:"errdefer"})," via ",(0,r.jsx)(e.code,{children:"return"}),"/",(0,r.jsx)(e.code,{children:"break"}),"/",(0,r.jsx)(e.code,{children:"continue"})," does not trigger it. Like ",(0,r.jsx)(e.code,{children:"defer"}),", ",(0,r.jsx)(e.code,{children:"errdefer"})," is structured: it only fires when the program leaves the scope of the entire ",(0,r.jsx)(e.code,{children:"errdefer"})," expression. So the following program is wrong:"]}),"\n",(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(e.pre,{className:"shiki shiki-themes one-light one-dark-pro",style:{backgroundColor:"#FAFAFA","--shiki-dark-bg":"#282c34",color:"#383A42","--shiki-dark":"#abb2bf"},tabIndex:"0",children:(0,r.jsxs)(e.code,{children:[(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:"let"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" result"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#56B6C2"},children:" ="}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" []"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:"for"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" x"}),(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" in"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" xs"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" {"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" let"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" res"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#56B6C2"},children:" ="}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" make_resource"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"x"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:")"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" errdefer"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" res"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"."}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:"close"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"}
1,children:"()"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" do_something_with_res"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"res"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:")"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" result"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"."}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:"push"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"res"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:")"})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"}"})}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"result"})})]})})}),"\n",(0,r.jsxs)(e.p,{children:["Here, each ",(0,r.jsx)(e.code,{children:"errdefer"})," only covers the single loop iteration it belongs to. After the first iteration completes, the program has left the scope of that iteration's ",(0,r.jsx)(e.code,{children:"errdefer"})," normally, so that ",(0,r.jsx)(e.code,{children:"errdefer"})," will never fire again. If the second iteration then fails, only the second iteration's own ",(0,r.jsx)(e.code,{children:"errdefer"})," fires, and the result of the first iteration leaks. The correct version is:"]}),"\n",(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(e.pre,{className:"shiki shiki-themes one-light one-dark-pro",style:{backgroundColor:"#FAFAFA","--shiki-dark-bg":"#282c34",color:"#383A42","--shiki-dark":"#abb2bf"},tabIndex:"0",children:(0,r.jsxs)(e.code,{children:[(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:"let"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" result"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#56B6C2"},children:" ="}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" []"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"errdefer"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" result"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"."}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:"each"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"res"}),(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" =>"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" res"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"."}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:"close"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"())"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:"for"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" x"}),(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" in"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" xs"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" {"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" let"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" res"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#56B6C2"},children:" ="}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" make_resource"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"x"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:")"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" do_something_with_res"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"res"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:")"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" result"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"."}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:"push"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"res"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:")"})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"}"})}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"result"})})]})})}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"defer"})," and ",(0,r.jsx)(e.code,{children:"errdefer"})," now support ",(0,r.jsx)(e.code,{children:"raise"})," and ",(0,r.jsx)(e.code,{children:"async"}),". Previously, the ",(0,r.jsx)(e.code,{children:"expr"})," in ",(0,r.jsx)(e.code,{children:"defer expr"})," could not raise errors or call async code. This restriction has been lifted. If an error is raised inside a ",(0,r.jsx)(e.code,{children:"defer"}),"/",(0,r.jsx)(e.code,{children:"errdefer"}),", the new error replaces the old one. When there are multiple ",(0,r.jsx)(e.code,{children:"defer"}),"/",(0,r.jsx)(e.code,{children:"errdefer"})," statements and one of them raises, the remaining ones still execute in order and are not discarded."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["Added a new warning for migrating ",(0,r.jsx)(e.code,{children:"catch"})," to ",(0,r.jsx)(e.code,{children:"defer"}),"/",(0,r.jsx)(e.code,{children:"errdefer"}),"."]}),"\n",(0,r.jsxs)(e.p,{children:["Currently, in ",(0,r.jsx)(e.code,{children:"moonbitlang/async"}),", a cancelled async program raises a special error as the cancellation signal, so that the cancelled program can release its resources. But this special error can be accidentally caught or transformed, causing the program to misbehave when cancelled. In the future, we plan to stop using a special error to represent the cancellation signal, and make ",(0,r.jsx)(e.code,{children:"catch"})," no longer catch it. However, if a program relies on ",(0,r.jsx)(e.code,{children:"catch"})," to perform resource cleanup, this change would prevent it from releasing resources correctly on cancellation. That is
1why we introduced ",(0,r.jsx)(e.code,{children:"errdefer"})," and lifted the side-effect restrictions on ",(0,r.jsx)(e.code,{children:"defer"}),": nearly all resource-release code can now be expressed with ",(0,r.jsx)(e.code,{children:"defer"}),"/",(0,r.jsx)(e.code,{children:"errdefer"})," (and the cancellation signal will continue to trigger ",(0,r.jsx)(e.code,{children:"defer"})," and ",(0,r.jsx)(e.code,{children:"errdefer"})," in the future)."]}),"\n",(0,r.jsxs)(e.p,{children:["To help users migrate existing ",(0,r.jsx)(e.code,{children:"catch"}),"-based resource-release code, we provide a new warning, ",(0,r.jsx)(e.code,{children:"fragile_catch_all"}),". It identifies ",(0,r.jsx)(e.code,{children:"catch"})," expressions that could likely be rewritten as ",(0,r.jsx)(e.code,{children:"defer"}),"/",(0,r.jsx)(e.code,{children:"errdefer"})," and emits a warning prompting migration. Besides handling async cancellation correctly in the future, ",(0,r.jsx)(e.code,{children:"defer"}),"/",(0,r.jsx)(e.code,{children:"errdefer"})," are also more readable and robust than ",(0,r.jsx)(e.code,{children:"catch"}),"."]}),"\n",(0,r.jsxs)(e.p,{children:["This new warning may produce false positives. If that happens, you can temporarily disable it for the current function with ",(0,r.jsx)(e.code,{children:'#warnings("-fragile_catch_all")'}),"."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"guard"})," now performs exhaustiveness checking and warns on non-exhaustive patterns. Users who want the previous panic-on-no-match semantics should migrate to ",(0,r.jsx)(e.code,{children:"guard!"})," to state that intent explicitly."]}),"\n",(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(e.pre,{className:"shiki shiki-themes one-light one-dark-pro",style:{backgroundColor:"#FAFAFA","--shiki-dark-bg":"#282c34",color:"#383A42","--shiki-dark":"#abb2bf"},tabIndex:"0",children:(0,r.jsxs)(e.code,{children:[(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:"fn"}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" main"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" {"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" let"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" string"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#56B6C2"},children:" ="}),(0,r.jsx)(e.span,{style:{color:"#C18401","--shiki-dark":"#E5C07B"},children:" Some"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:'"content"'}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:")"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" guard"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" string"}),(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" is"}),(0,r.jsx)(e.span,{style:{color:"#C18401","--shiki-dark":"#E5C07B"},children:" Some"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"content"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:")"})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#A0A1A7",fontStyle:"italic","--shiki-dark":"#7F848E","--shiki-dark-font-style":"italic"},children:" // ^~~~~~ Warning (guard_inexhaustive):"})}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#A0A1A7",fontStyle:"italic","--shiki-dark":"#7F848E","--shiki-dark-font-style":"italic"},children:" // This `guard` pattern is not exhaustive and will panic when"})}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#A0A1A7",fontStyle:"italic","--shiki-dark":"#7F848E","--shiki-dark-font-style":"italic"},children:" // it does not match. Missing cases:"})}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#A0A1A7",fontStyle:"italic","--shiki-dark":"#7F848E","--shiki-dark-font-style":"italic"},children:" // None"})}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#A0A1A7",fontStyle:"italic","--shiki-dark":"#7F848E","--shiki-dark-font-style":"italic"},children:" // To fix: add an `else { ... }` clause after the condition to"})}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#A0A1A7",fontStyle:"italic","--shiki-dark":"#7F848E","--shiki-dark-font-style":"italic"},children:" // handle those cases, or write `guard!` if the panic is intended."})}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" guard"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"! "}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"string"}),(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" is"}),(0,r.jsx)(e.span,{style:{color:"#C18401","--shiki-dark":"#E5C07B"},children:" Some"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"content"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:") "}),(0,r.jsx)(e.span,{style:{color:"#A0A1A7",fontStyle:"italic","--shiki-dark":"#7F848E","--shiki-dark-font-style":"italic"},children:"// the recommended new form"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" println"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"content"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:")"})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"}"})})]})})}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["Labelled blocks are now supported. Once a block is labelled, you can use ",(0,r.jsx)(e.code,{children:"break"})," with a value inside it to exit early, and that value becomes the result of the whole block."]}),"\n",(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(e.pre,{className:"shiki shiki-themes one-light one-dark-pro",style:{backgroundColor:"#FAFAFA","--shiki-dark-bg":"#282c34",color:"#383A42","--shiki-dark":"#abb2bf"},tabIndex:"0",children:(0,r.jsxs)(e.code,{children:[(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:"fn"}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" absolute"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"n"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" : "}),(0,r.jsx)(e.span,{style:{color:"#C18401","--shiki-dark":"#E5C07B"},children:"Int"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:") "}),(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:"->"}),(0,r.jsx)(e.span,{style:{color:"#C18401","--shiki-dark":"#E5C07B"},children:" Int"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" {"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" result"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"~: {"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" if"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" n"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#56B6C2"},children:" <"}),(0,r.jsx)(e.span,{style:{color:"#986801","--shiki-dark":"#D19A66"},children:" 0"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" {"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" break"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" result"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"~ (-"}),(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:"n"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:")"})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" }"})}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" n"})}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" }"})}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"}"})})]})})}),"\n",(0,r.jsxs)(e.p,{children:["Note that labelled blocks have no anonymous form: an unlabelled ",(0,r.jsx)(e.code,{children:"break"})," always targets the nearest loop, never a block. To avoid ambiguity, MoonBit specifies that an unlabelled ",(0,r.jsx)(e.code,{children:"break"})," appearing directly inside a labelled block is always an error, even when there is indeed an enclosing loop it could break out of. In that case you must use a label to state explicitly which layer of control flow to exit."]}),"\n",(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(e.pre,{className:"shiki shiki-themes one-light one-dark-pro",style:{backgroundColor:"#FAFAFA","--shiki-dark-bg":"#282c34",color:"#383A42","--shiki-dark":"#abb2bf"},tabIndex:"0",children:(0,r.jsxs)(e.code,{children:[(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:"fn"}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" f"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"}
1,children:"() "}),(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:"->"}),(0,r.jsx)(e.span,{style:{color:"#C18401","--shiki-dark":"#E5C07B"},children:" Int"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" {"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" for"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" ;; {"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#E45649","--shiki-dark":"#E06C75"},children:" label"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"~: {"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#A626A4","--shiki-dark":"#C678DD"},children:" break"}),(0,r.jsx)(e.span,{style:{color:"#986801","--shiki-dark":"#D19A66"},children:" 1"})]}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#A0A1A7",fontStyle:"italic","--shiki-dark":"#7F848E","--shiki-dark-font-style":"italic"},children:"// ^^^^^^^ An unlabelled `break` is not allowed directly inside a labelled block."})}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" }"})}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" }"})}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"}"})})]})})}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["Added a new reserved word: ",(0,r.jsx)(e.code,{children:"nocancel"}),"."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"#warnings"})," now also works on syntax warnings. Previously, ",(0,r.jsx)(e.code,{children:"#warnings"})," could only suppress warnings from the type-checking phase; some syntax warnings, such as ",(0,r.jsx)(e.code,{children:"deprecated_syntax"}),", could not be disabled through ",(0,r.jsx)(e.code,{children:"#warnings"}),". This has been fixed: ",(0,r.jsx)(e.code,{children:"#warnings"})," can now locally suppress most warnings, including syntax warnings. A few warnings that span top-level definitions, as well as lexical warnings, still cannot be suppressed with ",(0,r.jsx)(e.code,{children:"#warnings"}),"."]}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"toolchain-updates",children:"Toolchain Updates"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["The default target is now ",(0,r.jsx)(e.code,{children:"wasm"}),"."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"moon prove"})," now works out of the box as long as at least one supported solver (Z3 / Alt-Ergo / CVC5) is installed; a separate Why3 installation is no longer required. Correspondingly, Why3's ",(0,r.jsx)(e.code,{children:"data-dir"})," and ",(0,r.jsx)(e.code,{children:"lib-dir"})," can no longer be specified via environment variables; they are always read from ",(0,r.jsx)(e.code,{children:"~/.moon/share/why3/"})," and ",(0,r.jsx)(e.code,{children:"~/.moon/lib/why3/"}),"."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["You can now run executables from mooncakes.io with ",(0,r.jsx)(e.code,{children:"moonx username/example[@version]"})," (executed on the WASM backend by default; pass ",(0,r.jsx)(e.code,{children:"--target native"})," to run on the native backend):"]}),"\n",(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(e.pre,{className:"shiki shiki-themes one-light one-dark-pro",style:{backgroundColor:"#FAFAFA","--shiki-dark-bg":"#282c34",color:"#383A42","--shiki-dark":"#abb2bf"},tabIndex:"0",children:(0,r.jsxs)(e.code,{children:[(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:"$"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" moonx"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" moonbit-community/moongrep"})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:"error:"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" the"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" following"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" required"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" argument"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" was"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" not"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" provided:"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" 'subcommand'"})]}),"\n",(0,r.jsx)(e.span,{className:"line"}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:"Usage:"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" moongrep"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:" <"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:"comman"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"d>"})]}),"\n",(0,r.jsx)(e.span,{className:"line"}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:"Scan"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" MoonBit"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" source"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" files"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" with"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" structural"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" and"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" taint"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" rules."})]}),"\n",(0,r.jsx)(e.span,{className:"line"}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:"Commands:"})}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" scan"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" Scan"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" MoonBit"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" source"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" files."})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" lint"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" Scan"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" MoonBit"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" source"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" files"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" with"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" embedded"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" builtin"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" rules."})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" docs"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" Print"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" embedded"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" moongrep"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" documentation."})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" dump"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" Parse"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" a"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" MoonBit"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" impl"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" or"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" expression"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" and"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" print"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" untyped_ast"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" debug"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" output."})]}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" help"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" Print"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" help"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" for"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" the"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" subcommand"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:"("}),(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:"s"}),(0,r.jsx)(e.span,{style:{color:"#383A42","--shiki-dark":"#ABB2BF"},children:")"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:"."})]}),"\n",(0,r.jsx)(e.span,{className:"line"}),"\n",(0,r.jsx)(e.span,{className:"line",children:(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:"Options:"})}),"\n",(0,r.jsxs)(e.span,{className:"line",children:[(0,r.jsx)(e.span,{style:{color:"#4078F2","--shiki-dark":"#61AFEF"},children:" -h,"}),(0,r.jsx)(e.span,{style:{color:"#986801","--shiki-dark":"#D19A66"},children:" --help"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" Show"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" help"}),(0,r.jsx)(e.span,{style:{color:"#50A14F","--shiki-dark":"#98C379"},children:" information."})]})]})})}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["Added supp
1ort for ",(0,r.jsx)(e.code,{children:".moonignore"})," files."]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["Previously, whether files were included or excluded when publishing to mooncakes.io was configured by ",(0,r.jsx)(e.code,{children:".gitignore"})," plus the ",(0,r.jsx)(e.code,{children:'"exclude"'})," and ",(0,r.jsx)(e.code,{children:'"include"'})," fields in ",(0,r.jsx)(e.code,{children:"moon.mod"}),", which was somewhat cumbersome."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["Packaging now follows conventional ignore-file rules: the ",(0,r.jsx)(e.code,{children:".moonignore"})," in a folder \u2014 or, if absent, ",(0,r.jsx)(e.code,{children:".gitignore"})," \u2014 is used as the ignore file."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["By default, files and folders starting with ",(0,r.jsx)(e.code,{children:"."})," are ignored (this rule can be overridden via the ignore file), as is the ",(0,r.jsx)(e.code,{children:"_build"})," folder (not overridable)."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["The ",(0,r.jsx)(e.code,{children:'"exclude"'})," and ",(0,r.jsx)(e.code,{children:'"include"'})," fields in ",(0,r.jsx)(e.code,{children:"moon.mod"})," will be deprecated."]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["mooncakes.io previously allowed uploading packages whose names differ only in case (e.g. ",(0,r.jsx)(e.code,{children:"user/pkga"})," and ",(0,r.jsx)(e.code,{children:"user/pkgA"}),"). This causes problems on case-insensitive platforms, so mooncakes.io no longer allows uploading packages that differ only in case."]}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"standard-library-updates",children:"Standard Library Updates"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.code,{children:"moonbitlang/core"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:"QuickCheck updates"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["Two main testing entry points are now provided: ",(0,r.jsx)(e.code,{children:"@qc.check"})," (raises an error on failure, and prints nothing extra on success) and ",(0,r.jsx)(e.code,{children:"@qc.report"})," (returns a structured test report). Users can pass a function ",(0,r.jsx)(e.code,{children:"(A) -> Bool raise?"})," for property-based testing."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["You can pass a ",(0,r.jsx)(e.code,{children:"filter?: (A) -> Bool"})," parameter to the test functions to filter out generated values that do not meet requirements; the ",(0,r.jsx)(e.code,{children:"discard_ratio"})," parameter controls at what proportion of discarded values the test fails."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["The ",(0,r.jsx)(e.code,{children:"@qc.Generator[T]"})," type and related functions provide a set of common combinators to help build ",(0,r.jsx)(e.code,{children:"Arbitrary"})," instances."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["The ",(0,r.jsx)(e.code,{children:"core/quickcheck/shrink"})," package provides ",(0,r.jsx)(e.code,{children:"Shrinker"}),"s for most common types; once a counterexample is found, it can be shrunk to search for a smaller, simpler counterexample."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["Statistical analysis is supported: you can pass an observation combinator ",(0,r.jsx)(e.code,{children:"(A) -> Observation"})," to ",(0,r.jsx)(e.code,{children:"check"})," / ",(0,r.jsx)(e.code,{children:"report"})," via the ",(0,r.jsx)(e.code,{children:"observe?"})," parameter, where an ",(0,r.jsx)(e.code,{children:"Observation"})," can be constructed with the following functions:"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"@qc.label(val: String)"})," attaches a string label"]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"@qc.classify(cond: Bool, val: String)"})," attaches the label ",(0,r.jsx)(e.code,{children:"val"})," when the condition ",(0,r.jsx)(e.code,{children:"cond"})," holds"]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"@qc.collect(val : T)"})," uses a value's debug representation as the label"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["For more details, see the documentation: ",(0,r.jsx)(e.a,{href:"https://mooncakes.io/
1docs/moonbitlang/core/quickcheck",children:"https://mooncakes.io/docs/moonbitlang/core/quickcheck"})]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["New ",(0,r.jsx)(e.code,{children:"moonbitlang/core/diff"})," package"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["Provides two general-purpose sequence diff algorithms, Myers and Patience. Users can obtain the edit script between two sequences via ",(0,r.jsx)(e.code,{children:"@diff.Diff(old~, new~).edits()"}),"."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["Provides several functions for computing edit distances between sequences \u2014 ",(0,r.jsx)(e.code,{children:"edit_distance(ArrayView[T])"}),", ",(0,r.jsx)(e.code,{children:"edit_distance_str(StringView)"})," \u2014 along with variants that cap the maximum edit distance."]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["New ",(0,r.jsx)(e.code,{children:"moonbitlang/core/lexbuf"})," package, providing ",(0,r.jsx)(e.code,{children:"StringScanner"}),", ",(0,r.jsx)(e.code,{children:"Lexbuf"}),", and ",(0,r.jsx)(e.code,{children:"AsyncLexbuf"})," for use with ",(0,r.jsx)(e.code,{children:"lexscan"}),"."]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"StringScanner"}),": a synchronous ",(0,r.jsx)(e.code,{children:"String"}),"-based scanner; ",(0,r.jsx)(e.code,{children:"lexscan"})," maintains the ",(0,r.jsx)(e.code,{children:"cursor"})," field on the scanner."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"Lexbuf"}),"/",(0,r.jsx)(e.code,{children:"AsyncLexbuf"}),": streaming scanners whose data source is defined via ",(0,r.jsx)(e.code,{children:"Lexbuf::from_fn"}),"; they refill automatically during ",(0,r.jsx)(e.code,{children:"lexscan"}),". The difference between the two is that a ",(0,r.jsx)(e.code,{children:"lexscan"})," expression over an ",(0,r.jsx)(e.code,{children:"AsyncLexbuf"})," requires an async context as a whole."]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["The ",(0,r.jsx)(e.code,{children:"immut/array"})," package, deprecated for a long time, has now been formally removed; use ",(0,r.jsx)(e.code,{children:"immut/vector"})," instead."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"@debug.to_repr(x)"})," is deprecated; use ",(0,r.jsx)(e.code,{children:"@debug.Repr(x)"})," instead."]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"moonbitlang/async"})," is now at 0.21.0. The main updates since the last monthly report (0.20.2) are:"]}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"[breaking]"})," In the ",(0,r.jsx)(e.code,{children:"@http"})," package, the type of HTTP headers changed from ",(0,r.jsx)(e.code,{children:"Map[String, String]"})," to the case-insensitive ",(0,r.jsx)(e.code,{children:"type @http.Headers = Map[@http.CaseInsensitiveString, String]"}),", so you no longer need to handle case-folding manually when constructing or reading HTTP headers."]}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"@http.CaseInsensitiveString"})," can be implicitly constructed from ",(0,r.jsx)(e.code,{children:"String"}),", so code that builds headers with ",(0,r.jsx)(e.code,{children:"Map"})," literals or reads headers needs no changes."]}),"\n",(0,r.jsxs)(e.p,{children:["Code that wrote explicit type annotations for headers must change the type to ",(0,r.jsx)(e.code,{children:"@http.Headers"}),"."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"[breaking]"})," The ",(0,r.jsx)(e.code,{children:"create"})," and ",(0,r.jsx)(e.code,{children:"truncate"})," parameters of ",(0,r.jsx)(e.code,{children:"@fs.open"})," and related APIs had been deprecated for a while, replaced by ",(0,r.jsx)(e.code,{children:"create_mode"})," and ",(0,r.jsx)(e.code,{children:"permission"}),"."]}),"\n",(0,r.jsxs)(e.p,{children:["In this release, ",(0,r.jsx)(e.code,{children:"create"})," and ",(0,r.jsx)(e.code,{children:"truncate"})," are completely removed."]}),"\n",(0,r.jsxs)(e.p,{children:["In addition, the default ",(0,r.jsx)(e.code,{children:"create_mode"})," of ",(0,r.jsx)(e.code,{children:"@fs.write_file"})," and ",(0,r.jsx)(e.code,{children:"@process.redirect_to_file"})," changed from ",(0,r.jsx)(e.code,{children:"OpenExisting"})," to ",(0,r.jsx)(e.code,{children:"CreateOrTruncate"}),"."]}),"\n",(0,r.jsxs)(e.p,{children:["The default ",(0,r.jsx)(e.code,{children:"create_mode"})," of ",(0,r.jsx)(e.code,{children:"@fs.open"})," remains ",(0,r.jsx)(e.code,{children:"OpenExisting"}),"."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"[breaking]"})," The default behavior of ",(0,r.jsx)(e.code,{children:"@async.protect_from_cancel"})," is now ",(0,r.jsx)(e.code,{children:"resume_on_cancel=true"}),", and the ",(0,r.jsx)(e.code,{children:"resume_on_cancel=false"})," option is deprecated."]}),"\n",(0,r.jsxs)(e.p,{children:["Going forward, only the ",(0,r.jsx)(e.code,{children:"resume_on_cancel=true"})," behavior will exist."]}),"\n",(0,r.jsxs)(e.p,{children:["In ",(0,r.jsx)(e.code,{children:"moonbitlang/async"}),", cancellation is implemented by the runtime as a persistent attribute attached to each task."]}),"\n",(0,r.jsx)(e.p,{children:"Once a task is cancelled, it remains cancelled until it finishes, and users cannot revoke that state."}),"\n",(0,r.jsxs)(e.p,{children:["To help cancelled code release resources, the runtime notifies it with a special error, triggering ",(0,r.jsx)(e.code,{children:"defer"})," etc."]}),"\n",(0,r.jsx)(e.p,{children:"However, catching this cancellation signal does not change the fact that the current task is cancelled."}),"\n",(0,r.jsxs)(e.p,{children:["When cancelled, ",(0,r.jsx)(e.code,{children:"protect_from_cancel(resume_on_cancel=false)"})," guarantees the inner code runs to completion, then discards its result and raises the cancellation signal."]}
1),"\n",(0,r.jsx)(e.p,{children:"This is unsafe because the discarded result can lead to resource leaks."}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"protect_from_cancel(resume_on_cancel=true)"})," does swallow the cancellation signal, but it does not affect the cancelled state of the current task: the next async operation after it will still be cancelled, which makes ",(0,r.jsx)(e.code,{children:"resume_on_cancel=true"})," the more sensible behavior."]}),"\n",(0,r.jsx)(e.p,{children:"For most user code, this behavior change has no substantive impact."}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(e.hr,{}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"moonbitlang/async"})," now automatically detects deadlocks (e.g. two tasks waiting on each other) and forcibly terminates the program, preventing the event loop from spinning idly forever."]}),"\n",(0,r.jsxs)(e.p,{children:["You can use ",(0,r.jsx)(e.code,{children:"@async.set_deadlock_handler"})," to control the behavior on deadlock or to disable deadlock detection."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["Previously, ",(0,r.jsx)(e.code,{children:"moonbitlang/async"})," had to run its own event loop on the main thread, so it could not integrate with external event loops, such as those that ship with GUI frameworks."]}),"\n",(0,r.jsxs)(e.p,{children:["This update adds the ",(0,r.jsx)(e.code,{children:"@async.set_external_event_loop"})," API for installing an external event loop."]}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"moonbitlang/async"})," will run its own event loop on a separate thread and integrate it with the external loop on the main thread."]}),"\n",(0,r.jsx)(e.p,{children:"All MoonBit code still runs on the main thread."}),"\n",(0,r.jsxs)(e.p,{children:["For the APIs an external event loop implementation must provide to ",(0,r.jsx)(e.code,{children:"moonbitlang/async"}),", see the documentation of ",(0,r.jsx)(e.code,{children:"@async.set_external_event_loop"}),"."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["Added ",(0,r.jsx)(e.code,{children:"@process.pipe"}),", which redirects the output of one child process into the input of another."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"@process.read_from_process"})," and ",(0,r.jsx)(e.code,{children:"@process.redirect_to_file"})," gained a ",(0,r.jsx)(e.code,{children:"shared? : Bool = false"})," parameter."]}),"\n",(0,r.jsxs)(e.p,{children:["With ",(0,r.jsx)(e.code,{children:"shared=true"}),", the output pipe used for redirection can be passed to multiple child processes at the same time, but it must be closed manually with ",(0,r.jsx)(e.code,{children:".close()"})," after the last child process has started."]}),"\n",(0,r.jsxs)(e.p,{children:["With ",(0,r.jsx)(e.code,{children:"shared=false"})," (the default and previous behavior), the output pipe can only be passed to a single child process (though it may be passed to both ",(0,r.jsx)(e.code,{children:"stdout"})," and ",(0,r.jsx)(e.code,{children:"stderr"})," of that same process), and needs no manual close."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["Added the helper function ",(0,r.jsx)(e.code,{children:"@http.request"})," for performing a single HTTP request with an arbitrary method."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["The Wasm1 backend gained ",(0,r.jsx)(e.code,{children:"@websocket"})," and ",(0,r.jsx)(e.code,{children:"@fs.realpath"})," support; it now supports all functionality except ",(0,r.jsx)(e.code,{children:"@fs.Watcher"}),"."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["On Linux/macOS, when a child process is terminated by a signal rather than exiting normally, APIs such as ",(0,r.jsx)(e.code,{children:"@process.run"})," recognize this and return ",(0,r.jsx)(e.code,{children:"-signal"}),"."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["Previously, when an ",(0,r.jsx)(e.code,{children:"async fn main"})," program was cancelled by a signal, it would exit with ",(0,r.jsx)(e.code,{children:"128 + signal"})," as its exit code after releasing resources (the bash convention)."]}),"\n",(0,r.jsx)(e.p,{children:"But this is ambiguous to the parent process."}),"\n",(0,r.jsxs)(e.p,{children:["Now, when cancelled by a signal, ",(0,r.jsx)(e.code,{children:"async fn main"})," finishes cleanup and then re-simulates the state of the current process being forcibly terminated by that signal as the program's exit status."]}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(e.ol,{start:"3",children:["\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.code,{children:"moonbitlang/x"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["Deprecated ",(0,r.jsx)(e.code,{children:"moonbitlang/sys"}),"; use ",(0,r.jsx)(e.code,{children:"moonbitlang/core/env"})," instead."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"moonbitlang/x/path"})," now works correctly in browser environments, and Windows path comparison now correctly handles non-ASCII characters that have case forms."]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"moonbitlang/x/rational"})," no longer suffers from overflow misjudgments or zero-denominator issues."]}),"\n"]}),"\n"]}),"\n"]}),"\n"]})]})}function t(s={}){const{wrapper:e}={...(0,l.R)(),...s.components};return e?(0,r.jsx)(e,{...s,children:(0,r.jsx)(h,{...s})}):h(s)}},98703:(s,e,n)=>{n.d(e,{R:()=>c,x:()=>a});var i=n(79474);const r={},l=i.createContext(r);function c(s){const e=i.useContext(l);return i.useMemo((function(){return"function"==typeof s?s(e):{...e,...s}}),[e,s])}function a(s){let e;return e=s.disableParentContext?"function"==typeof s.components?s.components(r):s.components||r:c(s.components),i.createElement(l.Provider,{value:e},s.children)}},21274:s=>{s.exports=JSON.parse('{"permalink":"/updates/2026/08/19/index","source":"@site/updates/2026-08-19/index.md","title":"20260819 MoonBit v0.10.9 Release","description":"moonc version: v0.10.9","date":"2026-08-19T00:00:00.000Z","tags":[],"readingTime":12.41,"hasTruncateMarker":false,"authors":[],"frontMatter":{},"unlisted":false,"prevItem":{"title":"20260921 MoonBit v0.10.14 Release","permalink":"/updates/2026/09/21/index"},"nextItem":{"title":"20260713 MoonBit v0.10.4 Release","permalink":"/updates/2026/07/13/moonbit-0-10-4-release"}}')}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.