Skip to content

chore: support MoonBit 0.10.10 - #69

Merged
brickfrog merged 2 commits into
mainfrom
chore/moonbit-0-10-10
Aug 26, 2026
Merged

chore: support MoonBit 0.10.10#69
brickfrog merged 2 commits into
mainfrom
chore/moonbit-0-10-10

Conversation

@brickfrog

Copy link
Copy Markdown
Owner

Why

The repo does not compile under moonc 0.10.10. Two dependencies stopped parsing, for two separate undocumented language changes:

  • Loop-else was renamed to nobreak. moonbitlang/protobuf@0.1.1 uses for ... else in reader.mbt and async_reader.mbt → four E3002 parse errors.
  • A function-local struct declaration no longer parses. moonbitlang/async@0.19.0 declares one in js_async.mbt:116 → seven errors, js only, so a native-only check would have hidden it. js is a CI target.

Changes

Dependencies and toolchain

moonbitlang/protobuf 0.1.1 → 0.1.2 and moonbitlang/async 0.19.0 → 0.21.1. Upstream protobuf is already at 0.1.3, but mooncakes only publishes through 0.1.2, which compiles clean and needs no call-site changes.

The pinned CI toolchain in .github/scripts/setup-moonbit.sh moves 0.10.6 → 0.10.10+f8a486b6f, with digests computed from the archives. The script's layout assumptions still hold on the new tarball (no moonx binary shipped, so the ln -s does not collide; internal/tcc present) and both moon bundle steps were run against it locally.

HTTP headers

moonbitlang/async/http 0.21 keys headers by CaseInsensitiveString, so Map[String, String] no longer type-checks at @http.post_stream or on Response::headers. A key converts implicitly from String; a whole Map does not. Added to_http_headers at the @http boundary so the public OtlpHttpClient trait keeps plain Map[String, String].

Retry-After is now read straight off the case-insensitive map instead of going through parse_retry_after_ms, which probed the two literal casings retry-after and Retry-After. Casings such as Retry-after are now honored. parse_retry_after_ms(Map[String, String]) stays public and unchanged for callers holding a plain map.

New 0.10.10 diagnostics

E0092 fragile_catch_all flagged three catch-all handlers that cleaned up and re-raised. All three now release with defer, so state restore and span exit also run on the async cancellation paths a catch-all will stop capturing in a future compiler:

// before
try f() catch { err => { restore_trace_state(snapshot); raise err } }
  noraise { result => { restore_trace_state(snapshot); result } }

// after
defer restore_trace_state(snapshot)
f()

span_async cannot go all the way: errdefer runs on error and on cancellation but binds no error value, so recording the message needs a catch. The cleanup moved to defer, the handler now only inspects err, and the lint is suppressed locally with #warnings("-fragile_catch_all") and a comment.

E0020 on StringBuilder::newStringBuilder(), two sites.

Audit

Nothing else in the 0.10.7 → 0.10.10 range reaches this repo. No @immut/*, BigInt, from_octets, Deque, @diff, Iter2, Char::length, is_prefix/is_suffix, nocancel identifier, @debug.to_repr, or :embed prebuild. @json.parse appears only in tests, over payloads we generate. The trim(chars=) SIMD bug needs an empty character set; env_filter's is the non-empty ASCII constant " \t\r\n".

The default backend changing to wasm is a non-event here: moon.mod sets preferred_target = "native", and CI passes --target explicitly. The @fs create_mode default flip does not reach us either — every write_file/open call passes create_mode explicitly, and the removed create/truncate parameters were unused.

W0079 implicit_impl_as_method has 98 hits behind --warn-list +implicit_impl_as_method, all on derive(...) declarations. It is disabled by default and nothing breaks yet; migrating to explicit extend blocks is left out of this change.

Verification

  • moon check --deny-warn on native, js, wasm-gc and wasm: 0 warnings, 0 errors.
  • moon test: native 293/293, js 280/280, wasm-gc 265/265.
  • moon build --target native --release green.
  • moon info produces no .mbti diff — the public API is unchanged.
  • moon fmt idempotent.

client_test.mbt now has its test server send Retry-after, a casing the old two-literal probe would have missed, so the existing retry_after_ms == Some(2000) assertion exercises the case-insensitive lookup against a live @http.Server.

`moonbitlang/protobuf@0.1.1` and `moonbitlang/async@0.19.0` no longer parse
under moonc 0.10.10: loop-`else` was renamed to `nobreak` (four E3002 errors
in the protobuf reader) and a function-local `struct` declaration no longer
parses (seven errors in `js_async`, so the js target only). Move to
`protobuf@0.1.2` and `async@0.21.1` and bump the pinned CI toolchain from
0.10.6 to 0.10.10.

`moonbitlang/async/http` 0.21 keys headers by `CaseInsensitiveString`.
Convert at the `@http` boundary so the `OtlpHttpClient` trait keeps plain
`Map[String, String]`, and read `Retry-After` from the response with a
case-insensitive lookup instead of probing two literal casings.

Clear the new 0.10.10 diagnostics: E0092 `fragile_catch_all` on the three
catch-all-then-reraise scope guards, and E0020 on `StringBuilder::new`. The
guards now release with `defer`, so state restore and span exit also run on
the async cancellation paths a catch-all will stop capturing. `errdefer`
binds no error value, so `span_async` keeps a `catch` to record the error
message and suppresses the lint locally.

`moon info` reports no `.mbti` change. Checks pass with `--deny-warn` on
native, js, wasm-gc and wasm.
@brickfrog
brickfrog merged commit bbea4ac into main Aug 26, 2026
1 check passed
@brickfrog
brickfrog deleted the chore/moonbit-0-10-10 branch August 26, 2026 10:03
@brickfrog brickfrog mentioned this pull request Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant