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

moonbitlang / core / 5632 / 1
90%
main: 90%

Build:
DEFAULT BRANCH: main
Ran 28 Jul 2026 07:26AM UTC
Files 454
Run time 12s
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.477% (-0.8%) from 91.269%
5632.1

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>

15781 of 17442 relevant lines covered (90.48%)

173765.22 hits per line

Source Files on job 5632.1
  • Tree
  • List 454
  • Changed 10
  • Source Changed 2
  • Coverage Changed 10
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 5632
  • 84620dd3 on github
  • Prev Job for on main (#5628.1)
  • Next Job for on main (#5636.1)
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