Skip to main content

weekly-06-17

· 3 min read

Language Update

  • Supported error handling:
  1. Functions can now specify return types with error handling using the syntax Int!String. The following example means the function returns an Int under normal conditions, and throws an error of type String otherwise.
fn div(x: Int, y: Int) -> Int!String { .. }
  1. The raise keyword is used to interrupt the current control flow and throw an error. For example:
fn div(x: Int, y: Int) -> Int!String {
if y == 0 { raise "divide by 0" }
x / y
}
  1. The expression try { expr0 } catch { pattern1 => expr1; pattern2 => expr2; .. } can be used to catch errors thrown in expr0 and handle them with pattern matching. For example, the following function calls the div function and prints the error message if an error is thrown, then returns a default value:
fn div_with_default(x: Int, y: Int, default: Int) -> Int {
try {
div(x, y)!
} catch {
s => { println(s); default }
}
}
  1. Additionally, the suffix operators ! and !! are available for error handling. These operators can only be used on function calls: f(x)! rethrows any error immediately. f(x)!! panics on any error, equivalent to:
try { f(x)! } catch { _ => panic() }

Function calls include method calls, infix operators, and pipeline operators, such as:

fn init {
let _ = x.f()!!
let _ = (x + y)!!
let _ = (x |> f)!!
}
  1. Last, functions that might throw errors but do not use any of the above error handling mechanisms will result in an "unhandled error" error.
  • Support Map literal syntax.
fn init {
// Keys must be literals
let m1 : Map[String, Int] = { "x": 1, "y": 2 }
let m2 : Map[Int, String] = { 1: "x", 2: "y" }
}

IDE Update

  • Fixed a bug where methods from the builtin package would appear twice during autocompletion.

  • Fixed a bug where the Byte type was missing from autocompletion options.

Build System Update

  • Added support for internal packages. These packages are placed in a directory named internal and can only be imported by packages rooted in the parent directory of internal.

    For example, if a package is located at username/hello/x/internal/a, its parent directory is username/hello/x. Only username/hello/x and its subpackages (e.g., username/hello/x/a) can import username/hello/x/internal/a. However, username/hello/y cannot import this package.

weekly-06-11

· 2 min read

Language Update

  • Wasm MVP: Added reference counting support based on the Perceus algorithm to the Wasm1 backend.

  • Syntax: throw, raise, try, and catch are reserved as keywords in preparation for the upcoming error handling mechanism.

  • Core: List and sorted_map have been moved to core/immut

    • List has been moved to the core/immut/list package and is no longer supported as a built-in type.
    let a = @immut/list.List::Cons(1, Cons(2, Nil))
    • sorted_map has been moved to the core/immut/sorted_map package.
  • Core: JSON API has been optimized for better performance and to align with the new Core API.

    • New type definitions:
// Types and methods
pub enum JsonValue {
Null
// Previously Boolean(Bool)
True
False
Number(Double)
String(String)
Array(Array[JsonValue])
Object(Map[String, JsonValue]) // Previously @map.Map
}
  • JS: Optimized Int64 performance
    • On the JS backend, Int64 now compiles to two Int values, addressing the previous performance issues with compiling to BigInt. Additionally, the runtime implementation of Int64 in JS has been moved to the core standard library to facilitate open-source community review.

Build System Update

  • For moon.mod.json and moon.pkg.json, comments are supported when developing, but comments are not allowed when publishing (only standard JSON format is supported).

IDE Update

  • LSP: Function completion now displays parameter names. LSP.png

weekly-06-03

· 2 min read

Language Update

  • A new syntax T? has been added for type annotations to represent Option[T].
struct Cell[T] {
val: T
next: Cell[T]?
}

fn f(x : Cell[T]?) -> Unit { ... }

This is equivalent to

struct Cell[T] {
val: T
next: Option[Cell[T]]
}

fn f(x : Option[Cell[T]]) -> Unit { ... }

The old Option[T] is still compatible, but it is recommended to use the shorter new syntax. moonfmt will also format Option[T] as T?.

  • The core library API restructuring continues
    • The Iter package has been merged into the builtin package. Now Iter[T] can be used without the @iter. prefix.
pub fn any[T](xs : Iter[T], predicate : (T) -> Bool) -> Bool {
// ^no @iter. is required
match xs.find_first(predicate) {
None => false
Some(_) => true
}
}
  • The Stack package has been moved to moonbitlang/x

  • The List package has been removed, along with the to_list and from_list functions for various data structures. It is recommended to use Iter[T] and Array[T] for data structure conversion and intermediate representation.

  • Performance improvements

    • The compiler will now perform partial closure conversion during the separate compilation phase, improving compilation performance. Closure conversion has also been applied to code generated for the JavaScript backend in specific situations.
    • The types Option[Bool], Option[Char], Option[Byte], and Option[Unit] are now represented using 32-bit integers, where None is represented by -1 and Some(x) by x. The type Option[Int] is represented by a 64-bit integer in the wasm backend, where None is represented by 0x1_0000_0000, and Some(x) by x. In the JavaScript backend, Option[Int] is represented as int | undefined , where undefined represents None.
  • abort behavior change

    • To remove the dependency of Wasm programs on the non-standard spectest.print_char, the error output functionality is being restructured.
    • abort will no longer use spectest.print_char to print error messages. Its behavior will be the same as panic until the functionality is further improved.

    Plugin Update

  • [Language Server] Fixed a memory leak issue.

weekly-05-27

· 2 min read

MoonBit is a Rust-like programming language (with GC support) and toolchain optimized for WebAssembly.

Language Update

  • Breaking Change: Restructure APIs of MoonBit Core library.
    • Placing all immutable data structures under the immut path, for example, from @immutable_hashmap.Map to @immut/hashmap.Map.
// Before
let a : @immutable_hashmap.Map[Int, Int] = @immutable_hashmap.make()
// After
let a : @immut/hashmap.Map[Int, Int] = @immut/hashmap.make()
  • Performance optimization for the Option[T] type in the core library:
    • When the type T is a reference type, for values of type Option[T], Some(v) will be directly compiled into v, and None will be compiled into ref.null in the wasm-gc backend, or undefined in the JavaScript backend, thus avoiding memory allocation.
  • Introduced fn panicT -> T function in the core library, which can be used within test blocks where the test name must start with "panic":
test "panic test ok" {
panic() // Test passes
}

test "panic test failed" {
() // Test fails
}

IDE Update

  • VS Code extension: Added test and for code snippets. test snippet: test.gif for snippet: for.gif

Build System Update

  • Initialization: moon new now automatically initializes version control for new projects, currently supporting git
  • Testing: You can now specify multiple packages to test
moon test -p a b c
moon test -p a -p b -p c

Toolchain Update

  • Installation: You can now specify a version number for installation
# Mac and Linux Users
# Download the latest version
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
# Download the bleeding edge version
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash -s bleeding
# Download a specific version
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash -s 0.1.20240520+b1f30d5e1
# Windows Users
# Download the latest version
irm cli.moonbitlang.cn/install/powershell.ps1 | iex
# Download a specific version
$env:MOONBIT_INSTALL_VERSION = "0.1.20240520+b1f30d5e1"; irm cli.moonbitlang.cn/install/powershell.ps1 | iex

weekly-05-20

· 3 min read

MoonBit is a Rust-like programming language (with GC support) and toolchain optimized for WebAssembly.

Language Update

  • Breaking Change: Rename Array to FixedArray, @vec.Vec to Array
// Before
fn init {
let array : @vec.Vec[Int] = [1, 2, 3]
}
// After
fn main {
let array : Array[Int] = [1, 2, 3]
}
  • Add pattern matching support for Map, HashMap.
    • The type must implement the op_get method, where the key is a native type (Int, Char, String, Bool, etc.), and the value is an Option[T].
    • When matching, the key must be a literal.
    • In { "key": pat }, the pattern pat type is Option[T]. None means "key" does not exist, Some(p) means "key" exists, and p will be used to match the value of this key.
    • The pattern for matching key-value pairs is open: unmatched keys will be ignored even if they exist.
    • Key-value pair patterns will generate optimized code, with each key being queried at most once.
fn main {
let map = @map.Map::[ ("a", 1) ]
match map {
// Match when `map` contains "b",
// and bind the value of "b" in `map` to `y`.
{ "b": Some(y) } => println(y)
// Match when `map` does not contain "b" but contains "a",
// and bind the value of "a" to `k`.
{ "b": None, "a": Some(k) } => println(k)
// The compiler warns that the case { "b": None, "a": None } is not matched.
}
// Output: 1
}
  • Allow omitting the newtype constructor when type information is known.
type A Int

pub fn op_add(self : A, other : A) -> A {
self.0 + other.0 // omit the constructor
}

fn main {
A::A(0) + 1 |> ignore // omit the constructor of 1
let _c : A = 0 + 1 + 2
}

Build System Update

  • Configuration file options are converted to kebab-case (we'll still support snake_case for a while).
{
"is-main": true,
"test-import": []
}
  • Wasm, Wasm-GC: The backend supports specifying the exported memory name (default is moonbit.memory) and compile options (e.g., -no-block-params for compatibility with the Binaryen toolchain) in moon.pkg.json.
{ 
"link": {
"wasm": {
"export-memory-name": "custom_memory_name",
"flags": ["-no-block-params"]
},
}
  • moon check adds a --deny-warn option, treating warnings as failures and returning a non-zero exit code.
  • Optimized the execution speed of moon fmt and moon info.
  • moon fmt adds a --check option to check if the current code is formatted.

Core Update

  • Added an experimental library moonbitlang/x for developing and testing packages with unstable APIs. Once packages in moonbitlang/x are stable, we will select important packages to merge into moonbitlang/core based on community feedback.
    • num, time, uuid, and json5 have all been moved to moonbitlang/x.
  • The Bytes API moved from the Int type to the Byte type.
fn Bytes::op_get(self : Bytes, index : Int) -> Byte
fn Bytes::op_set(self : Bytes, index : Int, value : Byte) -> Unit
fn Bytes::length(self : Bytes) -> Int
fn Bytes::make(len : Int, ~init : Byte = b'\x00') -> Bytes

weekly-05-13

· 4 min read

MoonBit is a Rust-like programming language (with GC support) and toolchain optimized for WebAssembly.

Language Update

  • Support mutable fields in the payload of the constructor, here is how to use it:
enum E {
C(mut ~x : Int, mut ~y : Int)
} derive(Debug)


fn swap_xy(x : E) -> Unit {
match x {
// `~y` will bind to the value of the `y` field in the `C` before pattern matching.
// When encountering a pattern like `C(..) as c`, the compiler will know that `c` must be the constructor,
// so `c.x` and `c.y` can be directly accessed within the branch to access the fields of `C`.
C(~y, ..) as c => {
// `c.x` and `c.y` can be used to modify/read the latest values in `C`.
c.y = c.x
c.x = y
}
}
}

fn init {
let e : E = C(x=1, y=2)
debug(e) // C(x=1, y=2)
swap_xy(e)
debug(e) // C(x=2, y=1)
}

In this example, the swap_xy function swaps the values of the x and y fields of the constructor C, and this swap is done in-place without introducing additional memory allocation.

  • Array literals by default construct vectors. Array literal syntax has been overloaded. Now, array literals can be used to construct Vectors and Arrays, with the specific type determined by the context. If the type is ambiguous in the context, Vector is used by default, for example:
fn init {
let v = [1, 2, 3] // v has type @vec.Vec[Int]
let a : Array[_] = [1, 2, 3] // a has type Array[Int]
}

In the future update, Array will be FixedArray, Vec will be Array.

  • Error messages now include error codes, for example:
./vec/sort.mbt:68:16-68:23 [E4021] The value identifier minimum is unbound.
./vec/sort_by.mbt:90:16-90:23 [E4021] The value identifier minimum is unbound.
./vec/vec.mbt:962:37-962:50 [E4020] Package "iter" not found in the loaded packages.
./vec/vec.mbt:963:3-963:13 [E4024] The type/trait @iter.Iter is not found.

IDE Update

  • Support functionalities like gotodef/gotoref/rename for the labels of labeled fields in constructors, for example: label.PNG

Build System Update

  • Support configuring the warn list and alert list at the package level.
    • Configuration in moon.pkg.json is as follows, where you can disable corresponding warns and alters during compilation. (Here, 2, alter_1, and alert_2 are respectively the compiler's predefined warn id for Unused variable and user-defined alert id.)
{
"warn_list": "-2",
"alert_list": "-alert_1-alert_2"
}
  • - represents closing the corresponding id's warn and alter. Check the predefined warns with moonc build-package -warn-help.

  • The default backend for moon check|build|run|test has been switched from wasm to wasm-gc

  • The default execution mode for moon test has been changed from release to debug.

  • moon check|build|run|test now supports automatic dependency installation without the need to manually execute moon install

  • moon doc --serve now supports specifying the address and port.

-b, --bind <BIND> [default: 127.0.0.1]
-p, --port <PORT> [default: 3000]
  • Optimize moon size.
PlatformBeforeAfter
macOS arm647.3 MiB3.6 MiB
macOS x86_648.2 MiB4.1 MiB
Ubuntu x86_6414.0 MiB9.6 MiB
Windows x86_649.4 MiB4.9 MiB

Toolchain Update

  • moonrun now supports printing backtrace. Sample: Create a new project with moon new hello, and replace main/main.mbt with:
  fn bar() -> Unit {
abort("")
}

fn foo() -> Unit {
bar()
}

fn main {
foo()
}

Execute moon run main --debug, and you will see output similar to:

error: RuntimeError: unreachable
at $username/hello/main.bar.fn/1 (wasm://wasm/6fe99e5e:wasm-function[3]:0xe6)
at $username/hello/main.foo.fn/2 (wasm://wasm/6fe99e5e:wasm-function[4]:0xea)
at *init*/3 (wasm://wasm/6fe99e5e:wasm-function[5]:0xef)
at <anonymous>:9:22

weekly-04-30

· 4 min read

MoonBit is a Rust-like language (with GC support) and toolchain optimized for WebAssembly experience. This is our recent update:

  • MoonBit now supports JavaScript backend, up to 25x faster than native JS and 8x faster than Json5!

Read our latest blog and see how we did it: https://www.moonbitlang.com/blog/js-support

Play with this example and try MoonBit JS now: https://github.com/moonbit-community/benchmark-202404/tree/master/bench_json5

  • MoonBit now allows passing callback functions to FFI. However, the parameters and return types of callback functions are currently limited to simple types such as Int. Example:
// Example: passing a callback to external code
fn set_callback(f : () -> Int) = "ffi" "set_callback"

// Example
fn use_callback() -> Int = "ffi" "use_callback"

test {
let i = { val : 0 }
set_callback(fn () {
i.val += 1
i.val
})
inspect(use_callback(), content="1")?
inspect(use_callback(), content="2")?
inspect(use_callback(), content="3")?
inspect(use_callback(), content="4")?
}
let f

export default {
// Necessary external interface: converting a closure to a JS function. Implementation varies in different runtimes depending on the language.
'moonbit:ffi': {
make_closure: (funcref, context) => funcref.bind(null, context)
},
// Example
ffi: {
set_callback: (func) => {
f = func
}, // Set callback function
use_callback: () => f() // Use callback function
}
}
  • Modified the syntax for explicitly implementing a trait (extension method), allowing explicitly specifying which type is implementing the trait.
// Provide a default implementation for method method of trait Trait
impl Trait with method(...) { ... }

// Implement method method of trait Trait for type Type
impl Trait for Type with method(...) { ... }

// With type parameters
impl[X] Trait for Array[X] with method(...) { ... }

Compared to the previous syntax fn Trait::method(...), the new syntax allows explicit specification of the implementing type, providing richer and clearer signature information. Since the type is specified, the compiler can automatically infer the method's parameter and return types, eliminating the need for manual annotations:

trait MyTrait {
f(Self) -> Option[Int]
}

// No need to annotate `self` and the return type
impl MyTrait for Int with f(self) {
// Compiler can automatically infer that the return type is `Option[Int]`
Some(self)
}
  • Support Bytes literals.

Bytes literals b"..." will convert the ASCII string inside the double quotes to the Bytes type, with support for hexadecimal and octal escapes within the string.

 let b1 : Bytes = b"ASCII"
let b2 : Bytes = b"\xFF\o000"
  • Fixed the issue where { x } is too ambiguous.

Now { x } will be parsed as a struct with only one x field, equivalent to { x: x }. For this potentially confusing syntax, the compiler will issue a warning.

IDE Update

  • Added the option moonbit.autoUpdate in plugins to control whether to enable automatic update prompts.
  • Plugins now support multi-backend development:
    • Users can choose different backends within VSCode.
    • The code diff visibility decreases for non-current backends.

plugins.gif

Build System Update

  • Support for backend-specific files, where these files have extensions named with .wasm|wasm-gc|js.mbt, for example: foo.wasm.mbt, foo.wasm-gc.mbt, foo.js.mbt. For instance, in moon build --target js, only regular .mbt files and .js.mbt files will participate in the build. Accordingly, modifications have been made to moon check|build|test and the linking process in moonbitlang/core to be backend-specific.
  • In the moon.pkg.json file, a new format field is added to ["link"]["js"], used to specify the output JavaScript module format. Possible values are esm|cjs|iife, with the default being esm.
    • In esm mode, export { x as y } statements are used for exporting.
    • In cjs mode, exports.y = x is used for exporting.
    • In iife mode, globalThis.y = x is used for exporting.

Example moon.pkg.json:

{
"link": {
"js": {
"exports": [
"hello"
],
"format": "cjs"
}
}
}

  • moon test -u now supports automatically updating multiple inspect functions within test blocks, and adds the -limit option to restrict the maximum number of iterations for automatic updates.

Toolchain Update

  • moonrun has switched from wasmtime to V8, now supporting the wasm-gc backend.
moon new hello
cd hello
moon run main --target wasm-gc
  • moon info update
    • Support grouping methods to facilitate comparison between implementations of different data structures.
    • Support tagged parameters, default parameters, and automatic parameter filling.
type Map
impl Map {
debug_write[K : Debug, V : Debug](Self[K, V], Buffer) -> Unit
elems[K, V](Self[K, V]) -> List[V]
fold[K, V, T](Self[K, V], (T, V) -> T, ~init : T) -> T
from_array[K : Compare + Eq, V](Array[Tuple[K, V]]) -> Self[K, V]
// ...
}

weekly-04-22

· 4 min read

MoonBit is a Rust-like language (with GC support) and toolchain optimized for WebAssembly experience. This is our recent update:

Language Update

  • The standard library has added the Iter type, which efficiently accesses elements in a container and optimizes the access process into a loop. Here's an example of how to use it:
test "iter" {
let sum = Iter::[1, 2, 3, 4, 5, 6]
.filter(fn { x => x % 2 == 1 })
.take(2)
.map(fn { x => x * x})
.reduce(fn (x, y) { x + y }, 0)
inspect(sum, content="10")?
}
  • A VecView type has been added to the standard library, and you can obtain its VecView[T] for values of type Vec[T] using the following method.
test "view" {
let v = Vec::[1, 2, 3, 4, 5]
let vv1 = v[..]
let vv2 = v[1..]
let vv3 = v[..4]
let vv4 = v[1..4]
inspect(vv1, content="VecView::[1, 2, 3, 4, 5]")?
inspect(vv2, content="VecView::[2, 3, 4, 5]")?
inspect(vv3, content="VecView::[1, 2, 3, 4]")?
inspect(vv4, content="VecView::[2, 3, 4]")?
}
  • The array pattern supports the form [a, .. as rest, b], where rest will be bound to a VecView.
test "view_pattern" {
fn is_palindrome(s: VecView[Int]) -> Bool {
match s {
[] => true
[_] => true
[x, .. as rest, y] => x == y && is_palindrome(rest)
}
}
let v1 = Vec::[1, 2, 3, 4, 5]
@assertion.assert_false(is_palindrome(v1[..]))?
let v2 = Vec::[1, 2, 3, 2, 1]
@assertion.assert_true(is_palindrome(v2[..]))?
}
  • Allow the omission of the tilde ~ inside tags when calling tag parameters, for example:
inspect(1, content="1")
  • Constructor now supports labelled arguments:
enum Tree[X] {
Nil
Branch(X, ~left : Tree[X], ~right : Tree[X])
}

fn leftmost[X](self : Tree[X]) -> Option[X] {
loop self {
Nil => None
// use `label=pattern` to match labelled arguments of constructor
Branch(top, left=Nil, right=Nil) => Some(top)
// `label=label` can be abbreviated as `~label`
Branch(_, left=Nil, ~right) => continue right
// use `..` to ignore all remaining labelled arguments
Branch(_, ~left, ..) => continue left
}
}

fn init {
// syntax for creating constructor with labelled arguments is the same as callig labelled function
let t: Tree[Int] = Branch(0, right=Nil, left=Branch(1, left=Nil, right=Nil))
println(t.leftmost()) // `Some(1)`
}
  • The default value of optional parameters can depend on preceding parameters, for example:
fn f(~x: Int = 1, ~y: Int = x) -> Int {
x + y
}
  • Byte literals support octal escapes.

Byte.PNG

IDE Update

  • IDE supports test codelens for local environments and automatic updates for expect tests.

test-codelens.GIF

  • Fixed an issue where the online IDE couldn't find core on Windows.

  • Support for identifying test_import and *_test.mbt files.

Toolchain Update

  • moonfmt

    • Fixed an issue where escape sequences in String and Char literals were not formatted correctly.
    • Adjusted formatting for { ..record }
  • moon info and moon coverage now support Windows.

  • moon info supports shortening type names when it doesn't cause ambiguity, making the generated results cleaner. - Hide the builtin package name prefix when there is no type definition with the same name. - Use the last part of the package name instead of the full package name when there is no ambiguity. Before:

package moonbitlang/core/map

// -- snip --

type Map
fn Map::debug_write[K : @moonbitlang/core/builtin.Debug, V : @moonbitlang/core/builtin.Debug](Map[K, V], @moonbitlang/core/builtin.Buffer) -> Unit
fn Map::keys_set[K : @moonbitlang/core/builtin.Compare + @moonbitlang/core/builtin.Eq, V](Map[K, V]) -> @moonbitlang/core/immutable_set.ImmutableSet[K]
fn Map::lookup[K : @moonbitlang/core/builtin.Compare + @moonbitlang/core/builtin.Eq, V](Map[K, V], K) -> Option[V]
fn Map::to_vec[K, V](Map[K, V]) -> @moonbitlang/core/vec.Vec[Tuple[K, V]]

After:

package moonbitlang/core/map

alias @moonbitlang/core/immutable_set as @immutable_set
alias @moonbitlang/core/vec as @vec

// -- snip --

type Map
fn Map::debug_write[K : Debug, V : Debug](Map[K, V], Buffer) -> Unit
fn Map::keys_set[K : Compare + Eq, V](Map[K, V]) -> @immutable_set.ImmutableSet[K]
fn Map::lookup[K : Compare + Eq, V](Map[K, V], K) -> Option[V]
fn Map::to_vec[K, V](Map[K, V]) -> @vec.Vec[Tuple[K, V]]

Build System Update

  • moon test adds options related to test filtering:
-p, --package <PACKAGE_NAME>  Run test in the specified package
-f, --file <FILE> Run test in the specified file, only valid when --package is specified
-i, --index <INDEX> Run the index-nth test in the specified file, only valid when --file is specified

Command example: moon test -p username/hello/A -f hello.mbt -i 0 (runs the 0th test block in the hello.mbt file in the username/hello/A package); -f and -i are effective only when specified with -p; if -f is not specified, all tests in the package specified by -p will be run, and if -i is not specified, all tests in the file specified by -f will be run.

  • moon check|build|test adds the -sort-input option for generating stable build orders.

  • The ~content= generated by expect tests omits the ~ and is changed to content=.

weekly-04-15

· 2 min read

MoonBit is a Rust-like language (with GC support) and toolchain optimized for WebAssembly experience. This is our recent update:

Core Update

We have received 221 Repositories to MoonBit core since its open source in March, with 26 excellent contributors contributing about 10,000 lines of code of high quality. Thanks a lot for your passion and support for MoonBit!

0.PNG

Language Update

  • Expanded array patterns in pattern matching.

    • Support the vec type in the standard library.
    • Support for generic types [a, .., b].
    fn main {
    let xs = @vec.from_array([1, 2, 3])
    match xs {
    [1, .., 3] => { println("ok")}
    _ => println("not ok")
    }
    // Output: ok
    }

IDE Update

  • Changed the printing output of the online IDE from the Output channel to the terminal. Fixed the issue where the printing output was occasionally truncated in Firefox browsers. ANSI escape sequences can be used in browser code, for example:

1.PNG

  • Support autocompletion in the form of x |> @pkg.

1.5.PNG

  • Disabled inlay hint for matrix functions.

Before

2.PNG

After

3.PNG

Toolchain Update

  • Added (experimental) test coverage tools. (*Windows is not supported at the moment)

    • Added -enable-coverage option to moon test for enabling coverage during runtime.
    • Added moon coverage command for reading and processing coverage data.
      • After testing, moon coverage report -f <format> can be used to output coverage data. Supported output formats include:
        • bisect (default output format of OCaml Bisect tool)
        • html (output result webpage)
        • coveralls (JSON format suitable for CodeCov and Coveralls tool upload)
        • summary (output summary in the terminal) More functionalities can be viewed through moon coverage report -h.
      • moon coverage clean command can be used to clean up previous coverage data output.
  • The build system has added the moon info command for generating public interface files of software packages. (*Windows is not supported at the moment) Example:

    $ moon new hello
    $ cd hello
    $ moon info
    $ cat lib/lib.mbti
    package username/hello/lib

    // Values
    fn hello() -> String

    // Types and methods

    // Traits

    // Extension Methods
    ```

  • Fixed the issue where the annotation was misaligned caused by trailing commas in moonfmt.

  • Fixed the issue where file paths cannot contain spaces in moon.

weekly-04-08

· One min read

MoonBit Update

  • Support array.iter intrinsic and annotate functions in the standard library, enabling inline loops in specific cases to improve runtime efficiency.

    /// @intrinsic %array.iter
    pub fn iter[T](self : Array[T], f : (T) -> Unit) -> Unit {
    for i = 0; i < self.length(); i = i + 1 {
    f(self[i])
    }
    }

Toolchain Update

  • Support the experimental code coverage tool:
    • The tool has experimentally supported MoonBit Core CI.
    • We are optimizing the user-facing interface.

image

image

  • By default, the unsafe/throw/raise warnings in Alerts pragmas are turned off, while deprecated alerts are enabled.
  • moonfmt
    • Fixed an issue where comments were misaligned after printing literals with negative signs.
    • Fixed an issue where parentheses disappeared after printing literals with negative signs.
  • Fixed variable highlighting.
  • moonrun now supports printing UTF-16 strings.

Build System Update

  • expect test now supports Unicode characters.

image