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

moonbitlang / core / 5174

16 Jul 2026 07:11AM UTC coverage: 91.264% (+0.03%) from 91.237%
5174

push

github

bobzhang
refactor: adopt or-pattern `with` defaults to merge match arms

Use the new `Pat1(x) | (Pat2 with x = default)` or-pattern syntax to
merge arms that previously duplicated a body with a fixed value for a
binder (each `with` alternative is enclosed in parentheses, with a
flat binding list: `(Pat with a = e1, b = e2)`):

- previously-inexpressible merges: argparse `arg_display` (multi-binder
  `(PositionalInfo(_) with short = None, long = None)`),
  `SortedSet::length`, `Iter::zip` size hint, `List::drop` /
  `List::remove_at`, and the regex smart constructors (`seq`/`alt`/
  `e_alt`)
- deduplicated arm bodies: `HashSet` capacity clamping, `json_inspect`,
  `assert_true` / `assert_false`, `@test.assert_not_eq`
- single-arm unwraps: `Option`/`Result` `unwrap_or{,_default}`,
  `SortedMap::get_or_default`, and the `end? : Int` slicing defaults in
  builtin view constructors

`unwrap_or_else` keeps its two arms: calls that may raise are not
allowed inside a `with` default value.

No public API changes (`pkg.generated.mbti` unchanged); all 6715 tests
pass.
Reviewed by Codex CLI (codex-cli 0.144.1): "No findings. The
order-sensitive merges at builtin/iterator.mbt, list/list.mbt preserve
precedence... exhaustiveness is unchanged."

Signed-off-by: Codex CLI <codex@openai.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

31 of 35 new or added lines in 18 files covered. (88.57%)

15722 of 17227 relevant lines covered (91.26%)

190896.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.82
/bytes/internal/regex_engine/ast/pattern.mbt


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc