refactor: clear every deprecation warning moon check reports - #180
Merged
Merged
Conversation
`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
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
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
moon checkreported 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:
670dd27StringBuilder::new()→StringBuilder()a1aed6fArray::new(capacity=..)→Array(capacity=..), and@fs.read_dir(..).to_array()→to_owned()f15b5d8@sys.{get,set,unset}_env_var/get_env_vars→ the same four inmoonbitlang/core/env6ddd9dacmd/git-bit's implicitly promotedOsFstrait methods → twoextenddeclarationse026dcf@sys.get_cli_args()→@env.args()7d15d30Array→FixedArrayThe three that were not plain renames
@env.args()is not a drop-in for@sys.get_cli_args(). On the JavaScript backend it returnsprocess.argvunchanged, while the deprecated function droppedargv[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.extendonly 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 anunused_valuewarning.is_dirhas exactly one such caller, in a whitebox test, and is qualified there instead.cmd/bitholds the sameOsFsbut needs nothing — it reaches the filesystem through&RepoFileSystemeverywhere.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 arrayArray[String]did, andFixedArray[Byte]arrives as aUint8Array— array-like, withlength, and exactly whatUint8Array.from(bytes ?? [])already produced from the plain array. The MoonBit side fills aFixedArray::makebuffer instead of pushing onto a growable array.moonbitlang/core/envgained an import inbitx_bitconfigand inbit_vfs(itsfor "test"block, where the one call site lives); the other seven packages already had it.moonbitlang/x/systhen has no user left in seven packages, so that import goes too —cmd/bitandcmd/git-bitkeep it, since@sys.exitand@sys.get_cli_argsare not deprecated and are still called there.Verification
moon checkfor 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 tossh-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 exerciseget/set/unsetround-trips most.moon build --target native --release modules/bit, then a smoke run of the binary:init,add,commit,status,logall behave,GIT_AUTHOR_*/GIT_COMMITTER_*/GIT_*_DATEland in the commit (read back with realgit log, which is the end-to-end proof that@env.get_env_varis equivalent),git fsckis clean, andbit grep --column -n -ostill reports the absolute columns.node tools/check-layers.mjsandtools/check-layer-guards.shpass.Not done / follow-ups
moon fmtwas 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.jsis a checked-in generated bundle that already differs from a fresh build by ~16.8k lines onmain(older compiler codegen), so regenerating the npm payloads is its own change, not this one.pkf run checkstill passes--warn-list=-27-20-82, i.e. deprecations stay suppressed there. With the tree clean, dropping-20would 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_aiimportsmoonbitlang/x/syswithout 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