Skip to content

refactor: clear every deprecation warning moon check reports - #180

Merged
mizchi merged 6 commits into
mainfrom
claude/gracious-shannon-stgn8x
Sep 17, 2026
Merged

mizchi merged 6 commits into
mainfrom
claude/gracious-shannon-stgn8x

Conversation

@mizchi

@mizchi mizchi commented Sep 17, 2026

Copy link
Copy Markdown
Member

Summary

moon check reported 1795 warnings on native and 10 on js, all deprecations that #179 left as a follow-up ("warning-only and left as is", ~1.5k sites). This clears all of them: every target is now 0 errors, 0 warnings.

Six commits, one per deprecation family, so each can be read on its own:

commit what sites
670dd27 StringBuilder::new() → StringBuilder() 304 in 144 files
a1aed6f Array::new(capacity=..) → Array(capacity=..), and @fs.read_dir(..).to_array() → to_owned() 18 + 3
f15b5d8 @sys.{get,set,unset}_env_var / get_env_vars → the same four in moonbitlang/core/env 1552 in 117 files
6ddd9da cmd/git-bit's implicitly promoted OsFs trait methods → two extend declarations 30
e026dcf JS entry points: @sys.get_cli_args() → @env.args() 2
7d15d30 JS FFI signatures: Array → FixedArray 8

The three that were not plain renames

  • @env.args() is not a drop-in for @sys.get_cli_args(). On the JavaScript backend it returns process.argv unchanged, while the deprecated function dropped argv[0], the runtime executable. Both JS entry points index from the script path, so they drop it at the source rather than shifting every index below.

  • extend only lists the methods that are actually called. It makes a promoted method look like a function the package defines, so listing one no caller reaches (readdir, mtime, remove_file, remove_dir) trades the deprecation for an unused_value warning. is_dir has exactly one such caller, in a whitebox test, and is qualified there instead. cmd/bit holds the same OsFs but needs nothing — it reaches the filesystem through &RepoFileSystem everywhere.

  • The JS FFI bodies are unchanged, because the representation they see is compatible. Measured with a throwaway module on this toolchain: FixedArray[String] arrives as the same plain JS array Array[String] did, and FixedArray[Byte] arrives as a Uint8Array — array-like, with length, and exactly what Uint8Array.from(bytes ?? []) already produced from the plain array. The MoonBit side fills a FixedArray::make buffer instead of pushing onto a growable array.

moonbitlang/core/env gained an import in bitx_bitconfig and in bit_vfs (its for "test" block, where the one call site lives); the other seven packages already had it. moonbitlang/x/sys then has no user left in seven packages, so that import goes too — cmd/bit and cmd/git-bit keep it, since @sys.exit and @sys.get_cli_args are not deprecated and are still called there.

Verification

  • moon check for native, js and wasm: 0 errors, 0 warnings each (from 1795 / 10 / 0).
  • moon test --target js -p mizchi/bit_lib: 361/363. The two failures are the ssh-ed25519 signing tests that shell out to ssh-keygen, which is not installed in this sandbox — the same two build: follow moonbit 0.10.13 and moonbitlang/async 0.22, update all deps #179 saw.
  • node --test tools/npm-lib.test.mjs tools/npm-cli.test.mjs tools/js-build.test.mjs: 5/5, against freshly built payloads, so the JS host's byte-writing path and the relay transport's header path both run through the changed FFI. The tree-shaken bundle is 174,389 raw / 40,246 gzip bytes, just under its 174,458 / 40,265 baseline.
  • moon test --target native -p mizchi/bit_runtime -p mizchi/bitx_bitconfig: 26/26 — the two modules that exercise get/set/unset round-trips most.
  • moon build --target native --release modules/bit, then a smoke run of the binary: init, add, commit, status, log all behave, GIT_AUTHOR_* / GIT_COMMITTER_* / GIT_*_DATE land in the commit (read back with real git log, which is the end-to-end proof that @env.get_env_var is equivalent), git fsck is clean, and bit grep --column -n -o still reports the absolute columns.
  • node tools/check-layers.mjs and tools/check-layer-guards.sh pass.
  • The six commits were re-derived from a clean tree and verified byte-identical to the state all of the above ran against.

Not done / follow-ups

  • moon fmt was deliberately not run. On this toolchain it reformats 123 files this change never touches, so the tree is not fmt-clean independently of this work; worth a separate pass.
  • npm/hub.raw.js is a checked-in generated bundle that already differs from a fresh build by ~16.8k lines on main (older compiler codegen), so regenerating the npm payloads is its own change, not this one.
  • pkf run check still passes --warn-list=-27-20-82, i.e. deprecations stay suppressed there. With the tree clean, dropping -20 would keep it that way; the cost is that a toolchain bump turns new deprecations into a red CI, so that call is left to you.
  • bitx_rebase_ai imports moonbitlang/x/sys without using it — pre-existing, not caused by this change, left alone.

🤖 Generated with Claude Code

https://claude.ai/code/session_0134zgvUroAxAAggLS9yufPX


Generated by Claude Code

`StringBuilder::new()` is deprecated in moonbitlang/core in favour of
calling the type as a constructor, and it was the single largest source
of warnings in `moon check`: 304 call sites across 144 files.

No behaviour change — `StringBuilder()` is the same zero-argument
constructor under a new spelling, and no call site passed `size_hint`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0134zgvUroAxAAggLS9yufPX
Two more moonbitlang/core renames `moon check` flags: `Array::new(
capacity=..)` is now spelled `Array(capacity=..)` (18 sites), and the
`ArrayView` that `@fs.read_dir` returns since moonbitlang/x 0.5 is
materialised with `to_owned` rather than the deprecated `to_array` (the
three `RepoFileSystem::readdir` impls).

Two call sites that the collapsed form pushed past 80 columns are broken
across lines the way the formatter would.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0134zgvUroAxAAggLS9yufPX
`@sys.get_env_var`, `set_env_var`, `unset_env_var` and `get_env_vars`
from moonbitlang/x are deprecated in favour of the same four functions in
`moonbitlang/core/env`, and they were the bulk of what `moon check`
reported: 1552 call sites across 117 files. The replacements have
identical signatures and semantics — `get_env_var` still answers `None`
for a key that is not set — so this is a rename, not a behaviour change.

`bitx_bitconfig` and `bit_vfs` gained the `moonbitlang/core/env` import
(the latter in its `for "test"` block, where its one call site lives);
the other seven packages already had it.

`moonbitlang/x/sys` then has no user left in seven packages, so the
import goes too. `cmd/bit` and `cmd/git-bit` keep it: `@sys.exit` and
`@sys.get_cli_args` are not deprecated and are still called there.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0134zgvUroAxAAggLS9yufPX
Reaching a trait method through the `impl` alone — `fs.read_file(path)`
on a concrete `OsFs` rather than on a `&RepoFileSystem` — is deprecated,
and `cmd/git-bit` did it at 30 call sites across eight files. One
`extend` declaration per trait, next to the impls, covers all of them:
`mkdir_p`, `write_file` and `write_string` from `FileSystem`, `is_file`
and `read_file` from `RepoFileSystem`.

Only those five: `extend` makes a promoted method look like a function
the package defines, so listing one no caller reaches — `readdir`,
`mtime`, `remove_file`, `remove_dir` — trades the deprecation for an
unused-function warning. `is_dir` has exactly one such caller, in a
whitebox test, and is qualified there instead.

`cmd/bit` holds the same `OsFs` but needs nothing: it reaches the
filesystem through `&RepoFileSystem` everywhere.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0134zgvUroAxAAggLS9yufPX
`@sys.get_cli_args()` is deprecated, and its replacement is not a
straight swap: on the JavaScript backend `@env.args()` returns
`process.argv` unchanged, while the old function dropped `argv[0]`, the
runtime executable. Both JS entry points index from the script path, so
they drop it at the source instead of shifting every index below.

Verified against the JS build (`moon build --target js --release
modules/bit`, run with node): `--version` prints the version, no
arguments prints the usage, and an unimplemented command still reports
`bit: 'status' is not supported in JS target` — the same behaviour as
before.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0134zgvUroAxAAggLS9yufPX
`Array` in a JavaScript FFI signature is deprecated in favour of
`FixedArray`, which the host and transport bridges used for byte payloads
and header name/value pairs.

The JS bodies are unchanged, because the representation they see is
compatible. Measured with a throwaway module on this toolchain:
`FixedArray[String]` arrives as the same plain JS array `Array[String]`
did, and `FixedArray[Byte]` arrives as a `Uint8Array` — array-like, with
`length`, and what `Uint8Array.from(bytes ?? [])` already produced from
the plain array. The MoonBit side fills a `FixedArray::make` buffer
instead of pushing onto a growable array.

Verified: `moon test --target js -p mizchi/bit_lib` passes 361/363 (the
two failures are the ssh-ed25519 tests that shell out to `ssh-keygen`,
which is not installed here), `node --test tools/npm-lib.test.mjs
tools/npm-cli.test.mjs` passes 3/3 against freshly built payloads, and
`node --test tools/js-build.test.mjs` passes 2/2 — the JS host writes
files through the changed byte path and the relay transport round-trips
through the changed header path. The tree-shaken bundle is 174,389 raw /
40,246 gzip bytes, just under its 174,458 / 40,265 baseline.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0134zgvUroAxAAggLS9yufPX
@mizchi
mizchi merged commit 1c06ed3 into main Sep 17, 2026
22 checks passed
mizchi pushed a commit that referenced this pull request Sep 17, 2026
A minor bump: every workspace module, its intra-workspace dependency
pins, `bit_version_tag` and `npm/package.json` move from 0.46.4 to
0.47.0 together, the way the previous releases did.

Since v0.46.4, `main` gained new capability rather than fixes alone,
which is what makes this a minor and not a patch:

- `bit serve --http`, a real listener for the Git smart protocol over
  many repositories (#178), with protocol v2 `ls-refs` on the
  upload-pack side and side-band-64k framing on receive-pack.
- The object-storage layer underneath it: `bit_objstore` with
  compare-and-swap writes, a write-ahead log over it, and an S3
  transport plus response headers and DELETE in `bit_io_native`.
- The toolchain move to MoonBit 0.10.13 / moonbitlang/async 0.22 with
  every third-party dependency at its latest release (#179), which
  changed the npm CLI payload to an ES module.
- A deprecation-free tree: `moon check` now reports no warnings on
  native, js or wasm (#180).

`moon check` passes for native, js and wasm after the bump — the
intra-workspace pins resolve consistently — and the JS build reports
`git version 2.47.0 (bit v0.47.0)`. Publishing is left to the
maintainer.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0134zgvUroAxAAggLS9yufPX
@mizchi mizchi mentioned this pull request Sep 17, 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.

2 participants