Skip to content

ci: add moon check --deny-warn gate - #70

Open
bobzhang wants to merge 5 commits into
masterfrom
health/ci-gates
Open

bobzhang wants to merge 5 commits into
masterfrom
health/ci-gates

Conversation

@bobzhang

@bobzhang bobzhang commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Missing gate: ci.yml ran moon check / moon -C tests check without --deny-warn (fmt gate already present via moon fmt && git diff --exit-code).

Change: ci.yml -> moon check --deny-warn and moon -C tests check --deny-warn.

Warning fixes (196 warnings -> 0, on every target)

  1. Generator pins bumped (parser/moon.pkg: moonbitlang/yacc@0.7.18 -> 0.7.23, moonbitlang/ulex@0.3.29 -> 0.3.30; codegen/codeblock_parser/moon.pkg: ulex@0.3.29 -> 0.3.30). The newer yacc emits explicit extend declarations and no inexhaustive guards, which removes ~60 warnings from parser/parser.mbt. parser.mbt regenerated; lexer.mbt/codeblock_parser.mbt output is unchanged by the ulex bump.
  2. implicit_impl_as_method (89): explicit pub extend T with Trait::{...} next to each type/impl for exactly the methods the warning lists, so the public API is unchanged (pkg.generated.mbti now lists these methods; the diff is additions only). Token's ToJson (from the %derive in parser.mbty, which yacc doesn't extend) is extended in the hand-written parser/parser_show.mbt.
  3. guard_inexhaustive (34): guard ... else { panic() }, which spells out the panic the guard already did. That includes the two guards in the parser.mbty grammar actions.
  4. deprecated: StringBuilder::new() -> StringBuilder() (in codegen, parser/lexer.mbtx and, in the tests module, jsonlexer.mbtx, bytes.mbtx, lexbuf.mbt; generated lexers regenerated). The Show impls of Token/ParseError call Debug::to_repr(self) instead of the deprecated to_repr method, with the same output.
  5. unused_package: removed moonbitlang/ulex/regex (root), core/int (codegen, only used inside a string template), util/eof_char_set (dot_tests), util/bounded_enum (util/char_set), and parser's black-box-test-only core/test (no black-box tests there; the wbtest import is kept). core/debug in util/diet moved to a for "test" import.
  6. parser/__snapshot__/spec.json updated: it snapshots the parsed lexer.mbtx, whose embedded code now reads StringBuilder(). Nothing else in it changed.

Local verification (moon 0.1.20260920): moon info --target all / moon fmt leave no diff (root and tests), moon check --deny-warn clean (root, also --target all) and moon -C tests check --deny-warn clean, moon test 38/38 and moon -C tests test 11/11 (same as before).

Decisions for review

  • Generator pin bump (yacc 0.7.23 / ulex 0.3.30) instead of hand-editing generated output.
  • All extends are plain pub (including Debug::{to_repr}) to keep the API identical. If some of these promotions aren't meant to be public (e.g. to_repr, or the util/automaton internals), you can mark those extends #deprecated, or remove them.
  • pub extend Token with ToJson::{to_json} sits in hand-written parser_show.mbt, because the yacc %derive doesn't generate it.
  • else { panic() } is used for the inexhaustive guards to preserve behaviour. Some of these may deserve real error handling.

Update for moon 0.1.20261012 / moonc v0.10.15 (added to this PR) — CI stays red until two releases

On the new toolchain neither master nor this branch can be built: the dependency moonbitlang/ulex-runtime@0.4.3 (the latest published version) ships a moon.mod.json, which is now a hard error ("is no longer supported. Run moon fmt to migrate"). moonbitlang/moonlex-runtime is already converted on its default branch, but not released yet.

Blocked on:

  1. a new release of moonbitlang/ulex-runtime (with moon.mod). Then bump the pin in moon.mod and tests/moon.mod.
  2. a new release of moonbitlang/yacc whose runtime template no longer emits @list.empty() (now deprecated in favour of List([])). With yacc@0.7.23 (the latest) the regenerated parser/parser.mbt has one such call (line 1674, state_stack), which fails moon check --deny-warn. Then bump the pin in parser/moon.pkg.

What this commit already does, so that only the two pin bumps remain:

  • moon fmt in the root module and in tests/ (Int → Int32, UInt → UInt32, x? : T = v → x~ : T = v): formatter output.
  • Deprecations named by the compiler: @list.empty() → @list.List([]) in the two grammar actions of parser/parser.mbty (parser.mbt regenerated by the build rule), x.to_json() → Json(x) in util/char_set, subset → is_subset in automaton.

Verified locally by replacing the unpacked ulex-runtime@0.4.3 in .mooncakes with the converted sources from moonlex-runtime's default branch (same version, same code; nothing of that is committed): moon info --target all and moon fmt leave no diff in both modules, moon -C tests check --deny-warn is clean, moon test 38/38 and moon -C tests test 11/11 (same as before). moon check --deny-warn in the root module reports exactly one remaining error, the generated line from item 2.

Also seen, not changed: moon prints "exclude in moon.mod is deprecated; use .gitignore or .moonignore" for options(exclude: [ "tests" ]) in both moon.mod files, and "moon runwasm is deprecated ... use moonx instead" for the build rules. Both are notices from moon, they do not fail the gates.

Note: source using Int32/UInt32 needs moon 0.1.20261012 or newer.

The newer generators emit warning-free code (explicit extend declarations,
no inexhaustive guards on semantic-value extraction). Regenerated parser.mbt.
- implicit_impl_as_method: add explicit pub extend declarations for the
  promoted trait methods, keeping the public API unchanged
- guard_inexhaustive: make the implicit panic explicit with else { panic() }
  (including the two guards in parser.mbty)
- deprecated: StringBuilder::new() -> StringBuilder(), Token/ParseError
  Show impls call Debug::to_repr(self) instead of the deprecated method
- unused_package: drop unused imports; core/debug in util/diet is test-only
- regenerate parser/lexer.mbt and tests/*.mbt lexers, update snapshot and
  pkg.generated.mbti
@bobzhang
bobzhang marked this pull request as ready for review October 2, 2026 10:35
0.4.4 is the first release with moon.mod. The remaining --deny-warn error is
one generated line in parser/parser.mbt (yacc 0.7.23 still emits
@list.empty()); it goes away with the next yacc release.
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