• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

moonbitlang / core / 5632
90%

Build:
DEFAULT BRANCH: main
Ran 28 Jul 2026 07:26AM UTC
Jobs 1
Files 453
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

28 Jul 2026 07:24AM UTC coverage: 90.461% (-0.8%) from 91.255%
5632

push

github

bobzhang
refactor: replace fall-through `match` with `guard ... is`

Rewrites the two-arm `match x { Pat => action; _ => () }` shape as
`guard x is Pat else { () }` followed by the action, which removes a
level of nesting and puts the interesting branch at statement level.

7 sites: `diff/diff.mbt`, `builtin/iterator.mbt`, and the `json` tests.

Found with moongrep, generalising past the `Option`-specific shape:

    moongrep scan --pattern 'match $(x:exp) {
      $(p1:pat) => $(action:exp)
      $(p2:pat) => ()
    }'

`$(pN:pat)` captures whole pattern ASTs, so it matches `Some(_)/None`,
`Number(n, ..)/_` and `['-', ..]/_` alike — 11 sites, against 5 for the
literal `Some($(p:pat))`/`None` shape.

**The rewrite is not unconditional.** `guard` skips the rest of the
enclosing block when it fails, whereas the `() ` arm falls through and
lets execution continue. So it is only equivalent when the `match` is
the *last* statement in its block. Four sites are left as-is:

- `diff/diff.mbt:160`, `diff/diff.mbt:222` and
  `string/internal/regex_parser/parser.mbt:160` are mid-block — code
  follows the `match`. Converting them would silently skip that code on
  the fall-through path. These want `if x is Pat { action }`, not
  `guard`, and are left alone here.
- `argparse/parser_validate.mbt:266` is in tail position and converts
  correctly, but its two-constructor or-pattern makes the `guard` header
  wrap across four lines and read worse than the `match`. Reverted on
  readability grounds.

Comments that annotated the `() ` arm are moved onto the `else` branch,
which is where that fall-through now lives.

Tests pass on wasm-gc, js and native; `moon info` reports no `.mbti`
change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

4 of 4 new or added lines in 2 files covered. (100.0%)

208 existing lines in 8 files now uncovered.

15752 of 17413 relevant lines covered (90.46%)

174054.61 hits per line

Coverage Regressions

Lines Coverage ∆ File
50
20.83
-52.08% encoding/utf8/decode_nonjs.mbt
48
15.79
-84.21% builtin/bytes_unsafe.mbt
37
21.28
-78.72% encoding/utf8/encode_nonjs.mbt
36
46.83
11.71% builtin/bytes_find.mbt
23
42.35
-27.06% v128/simd_memory.mbt
7
15.96
-7.45% v128/lanes.mbt
6
85.05
3.74% builtin/bytesview.mbt
1
97.78
-2.22% builtin/byte.mbt
Jobs
ID Job ID Ran Files Coverage
1 5632.1 28 Jul 2026 07:26AM UTC 454
90.48
GitHub Action Run
Source Files on build 5632
  • Tree
  • List 453
  • Changed 10
  • Source Changed 2
  • Coverage Changed 10
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • 84620dd3 on github
  • Prev Build on main (#5628)
  • Next Build on main (#5636)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc