changelog should follow Keep a Changelog conventions.
MoonBit Language Changes no need for such detailed classification.
- Core commit:
bd827dc85 - Added
Debugtrait withderive(Debug)support, includingignore=[..]configuration for non-debuggable nested types - Added new
moonbitlang/asyncAPIs including@process.spawn, advisory file locking,@fs.tmpdir,@async.all, and@async.any - Added
Array::release_unused(placeholder~), which overwrites the unused capacity of an array in place with a placeholder, releasing the elements that earlier removals left there - Added
Deque::release_unused(placeholder~), which overwrites the unused capacity of a deque in place with a placeholder, releasing the elements that earlier removals left there
Arrayshrinking operations no longer null out the slots they vacate, so anArrayViewcreated before the mutation can no longer read uninitialized memory (previously a segfault on native andnullon wasm-gc; the JavaScript backend is unchanged, and such a view still observesundefinedpast the array's current length there). Mutating an array while a view of it is alive remains a program error, but it now yields unspecified valid values rather than undefined behavior. The removed elements stay reachable from the buffer until later pushes reuse those slots, the buffer grows, or the array is dropped -- uniformly,clearincluded, which no longer releases them.Array::release_unused(placeholder~)overwrites the unused capacity in place with a placeholder to release them on demand, whileshrink_to_fit, which already reallocated, lets them go with the old buffer. No existing signature changesDequeshrinking operations no longer null out the slots they vacate, so anArrayViewobtained fromDeque::as_viewsbefore the mutation can no longer read uninitialized memory (previously a segfault on native,null/undefinedelsewhere). Mutating a deque while a view of it is alive remains a program error, but it now yields unspecified valid values rather than undefined behavior. The removed elements stay reachable from the buffer until later pushes reuse those slots, the buffer grows, or the deque is dropped -- uniformly,clearincluded, which no longer releases them.Deque::release_unused(placeholder~)overwrites the unused capacity in place with a placeholder to release them on demand, whileshrink_to_fit, which already reallocated, lets them go with the old buffer. No existing signature changes- BREAKING:
@json.parsenow rejects unpaired\uXXXXsurrogate escapes in strings, raisingParseError::InvalidCharat the backslash that opens the offending escape; an escaped leading surrogate must be followed immediately by an escaped trailing surrogate, and the pair decodes to the character it denotes. Previously such escapes were decoded unchecked and produced aStringthat was not well-formed Unicode.@json.validreports the same documents as invalid. JSON emitted byJSON.stringifyin JavaScript can contain these escapes, so input that JavaScript and Python accept may now be rejected — as it is by Rust's serde_json @json.inspecthas been migrated tojson_inspectString::subandStringView::subnow panic on invalid indices instead of raisingCreatingViewError. TheCreatingViewErrortype has been removed.
- BREAKING: Removed the
immut/arraypackage, whose entire API was deprecated. Useimmut/vectorinstead.
- Added
declarekeyword (replacing#declaration_only) for staged declarations, including declared impl relationships - Added reversed-range syntax
x>..y/x>=..yforfor .. in - Added user-defined
structconstructors (fn new+S::new) - Added panic backtrace support on wasm-gc/native/LLVM backends in debug mode
- Added
moon fetch,moon ide hover, andmoon ide renamesubcommands - Added
moon test -j,moon test --outline, and range form ofmoon test --index
for/while/for .. inloopelseblocks are now written withnobreakx..f()semantics are standardized as{ x.f(); x }, and ignored-return misuse now warnsmoon -C <path>now changes working directory semantics;--manifest-pathwas addedmoon runandmoon buildnow default to--debug.mbt.mddependency front matter supports package-level imports and aliasing
- Deprecated
suberror Err PayloadTypein favor of enum-likesuberrorsyntax - Deprecated
x..=yin favor ofx..<=yfor closed forward ranges - Deprecated effect inference for local
fnthat performsraise/asyncwithout explicit annotation - Deprecated
moon.pkg.jsonin favor ofmoon.pkg - Deprecated old
moon installbehavior (installing project dependencies)
- Core commit:
c0b22a8b0 moonbitlang/asyncnow supports Windows (MSVC), plus updates to@fs.mkdir(recursive) and process APIs- Experimental
lexmatchnow supports POSIX character classes like[:digit:]
- Added warning for unused
async - Optional argument default expressions can now
raise(when function signature allows it) - Added
#declaration_onlyfor staged/spec-driven declarations - Added pipeline shorthand
e1 |> x => e2 - Added loop invariants/reasoning annotations for
forloops - Added experimental
moon.pkgsupport (migration viaNEW_MOON_PKG=1 moon fmt) - Added
moon idesubcommands (peek-def,outline,doc) and doc-testmbt checksupport
SourceLocoutput now uses relative pathsmoon addnow runsmoon updateautomatically- New
moonbackend is enabled by default (NEW_MOON=0to switch back) - Build artifacts moved from
targetto_build(with atargetsymlink for compatibility) Iterinmoonbitlang/coremigrated to external iterator semantics (single-pass traversal)
- Inferring
Refthrough struct literal{ val: ... }is deprecated Iteratoralias and.iterator()methods are deprecated in favor ofIterand.iter()
- Export
FromJsontrait from@jsonpackage in prelude for easier JSON deserialization
- BREAKING:
String::atandStringView::atnow returnUInt16instead ofIntand are the primary methods for accessing UTF-16 code units - BREAKING:
String::code_unit_atandStringView::code_unit_atare now aliases foratinstead of being separate methods String::trim,String::trim_start,String::trim_endand theirStringViewcounterparts now accept optionalcharsparameter with default whitespace characters
String::charcode_at(previously namedat) is now deprecated, useString::atwhich returnsUInt16String::trim_spaceandStringView::trim_spaceare now deprecated, usetrim()with default whitespace characters instead
-
Introduced the
#declaration_onlyattribute for function, method, and type declarations. These declarations can be called or tested immediately but require a concrete implementation to function at runtime. Accessing a declaration without an implementation will result in a runtime crash. -
The compiler can now report unused warning on async annotations when the function is actually synchronous
-
moonfmtwill automatically migratembt test/mbt test(async)code blocks in Markdown tombt check.
-
The default value of optional arguments can now raise error or perform async operations, as long as the function itself allow these effects
-
Refactored the representation of JS backend trait objects. Each trait object now consists of two fields: the underlying data and a method table. This allows trait objects of the same type to share a single method table.
-
String::foldString::rev_foldStringView::foldStringView::rev_foldnow supports error polymorphism (#3034) -
ArrayView::getis added (#3025)
- The output format of
SourceLochas been changed (#3035)
Result::orResult::or_elseare deprecated in favor ofResult::unwrap_orResult::unwrap_or_else(#3031)- Passing
max_nesting_depthto@json.parseis deprecated. (#3028)
-
#moduleattribute now supports importing JS modules in CJS format -
Docstrings now support
mbt checkto mark MoonBit code blocks that participate in compilation. Currently,mbt checkblocks in docstrings have the following restrictions:- Only test code is allowed in
mbt checkblocks mbt checkblocks must not contain parse errors
- Only test code is allowed in
- An array literal without a type annotation that is bound to a local variable
is now inferred as
Array; if the variable is only read, or only read and written, the user is prompted to annotate it asReadOnlyArrayorFixedArray
- We will remove the previously added
mbt testandmbt test(async)support in the future, keeping onlymbt check
- Core commit:
b989ba000 - Added
MutArrayViewas the unified mutable slice type - Added
#module("...")support for importing third-party JS modules
ArrayViewis now the unified immutable slice forArray/FixedArray/ReadOnlyArraystring[x]now returnsUInt16(migrate tocode_unit_at)
- Deprecated
Container::ofin favor ofType::from_array(ArrayView[_]) - Renamed
@test.Tto@test.Testand@priority_queue.Tto@priorityqueue.PriorityQueue
ReadOnlyArraynow supports pattern matching, slicing, and spread- Bitstring patterns now support signed extraction
- Added
#label_migrationfor parameter-label alias/deprecation migration - Added warning mnemonics and
#warningslocal configuration - Added
test_unqualified_packagewarning (disabled by default) - Added
mbt testandmbt test(async)markdown/doc code blocks
- Cascade calls now allow non-
Unitintermediate returns withinvalid_cascadewarning mbt/moonbitcode blocks no longer type-check by default; usembt check- Default behavior changed for
#deprecated: now warns in current package unlessskip_current_package=true - Experimental
lexmatchnow supportsfirstmode with search/non-greedy behavior - Alerts are merged into warning configuration
- Core commit:
07d9d2445 - Added external iterator type support (
Iterator) withfor .. inintegration via.iterator()/.iterator2()
- Added
using @pkg { ... }as unified alias syntax for values, types, and traits - Added
#aliassupport for types and traits - Added duplicate test-name warnings
- Added experimental
lexmatch?and case-insensitive regex modifier(?i:...) - Added
ReadOnlyArraybuilt-in type for immutable fixed-length lookup tables - Added anti-pattern lint warnings for selected patterns
- Added
#deprecated(skip_current_package=...)parameter
- Bitstring patterns now require explicit endianness suffixes such as
u1beandu32le
traitalias,fnalias, andtypealiasare being migrated towardusing,type Alias = ..., and#alias- Deprecated
moon info --no-alias
- Core commit:
9037370fc - Added per-process randomized hashing to mitigate HashDoS risks
ArrayViewbecame immutable
- Added
async testandasync fn main(native backend on Linux/macOS) - Added experimental
lexmatchexpression forStringView/BytesView - Added unified
usingimports withpub usingsupport for re-export - Added optional parameters on trait methods
- Added
#aliasoperator-overloading aliases for methods like get/set/view - Released wasm toolchain packages for x86 Darwin and ARM Linux
- Added
.mbt.mdformatting support inmoon fmt
- Removed long-deprecated behavior where
fn meth(self : T, ..)could also be called as a plain function - Removed
direct_usefrommoon.pkg.json(replaced byusing)