Language Update
-
[Breaking change] Modified array slice syntax from
arr[start..end]toarr[start:end]similar to Python. This change is made to avoid syntax conflicts with the upcoming cascade method callx..f(). The old syntax will be deprecated soon. -
[Breaking change on wasm backend] Code in
fn initis now compiled into the start section.Previous versions compiled code from both
fn initandfn maininto a special function exported as “_start”, therefore, host environments needed to call “_start” for initialization and execution of themainfunction.The new version uses the wasm standard’s start section to execute
fn initduring module loading, eliminating the need to call “_start” forfn init. “_start” is only necessary when executingmain. -
[Breaking change]
test blockno longer returnsResulttype results.Error handling mechanisms are now used within test blocks to handle test failures. The standard library’s
inspectfunction and helpers like@test.eqfrom the@testpackage are encouraged for writing tests, for example:
test "unwrap should return value on Some" {
let some : Int? = Some(42)
inspect(some, content="Some(42)")!
@test.eq(some.unwrap(), 42)!
}
- Supports using
@pkg.Cto access constructors across packages. For example, if@pkgAcontains the following declaration:
// pkgA
pub enum E1 { C1 }
Now, in another package, E1’s constructor C1 can be directly used, for instance:
// pkgB
fn main {
debug(@pkgA.C1)
}
In the same package, encountering duplicate public constructors will result in an error, for example:
pub enum E1 {
C1
}
pub enum E2 {
C1
^^ ------ There can be at most one public constructor with name C1.
}
Core Update
-
Migrated to a new error handling mechanism.
-
Migrated to unsigned integers, removed old
compare_u,div_u,mod_ufunctions forIntandInt64types; API adjustments include: -
Int32.trunc_double_u,Int64.trunc_double_uchanged to
UInt.trunc_double,UInt64.trunc_double. -
Int64::extend_i32_uchanged toUInt64::extend_uint. -
Double::convert_i32_u,Double::convert_i64_uchanged to
Double::convert_uint,Double::convert_uint64.
Build System Update
moon version --alldisplays moonrun’s version information:
$ moon version --all
moon 0.1.20240705 (0e8c10e 2024-07-05) ~/.moon/bin/moon
moonc v0.1.20240705+7fdd4a042 ~/.moon/bin/moonc
moonrun 0.1.20240703 (52ecf2a 2024-07-03) ~/.moon/bin/moonrun
-
Modified
moon newproject creation to default thelicensefield to empty. -
Diagnostics information rendering is now enabled by default.
Toolchain Update
- VSCode plugin defaulted to installing the corresponding plugin version’s toolchain, changed from always installing the latest version.
