Skip to content

codegen.c: raise NoMatchingPatternError in case/in without else#6744

Merged
matz merged 2 commits intomasterfrom
fix/case-in-no-match-error
Mar 12, 2026
Merged

codegen.c: raise NoMatchingPatternError in case/in without else#6744
matz merged 2 commits intomasterfrom
fix/case-in-no-match-error

Conversation

@matz
Copy link
Copy Markdown
Member

@matz matz commented Mar 12, 2026

Summary

  • case/in without else clause now raises NoMatchingPatternError when no pattern matches, matching CRuby behavior
  • The OP_MATCHERR opcode was already implemented and used for one-line pattern matching (expr => pattern), but was not emitted for case/in

Fixes #6741

Test plan

  • All existing tests pass (1842 OK, 111 bintests OK)
  • Updated test to assert NoMatchingPatternError is raised
  • case/in with else clause still works correctly

case/in without else clause now raises NoMatchingPatternError
when no pattern matches, matching CRuby behavior. Fixes #6741.

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
@matz matz merged commit 457a50b into master Mar 12, 2026
28 of 32 checks passed
@matz matz deleted the fix/case-in-no-match-error branch March 18, 2026 04:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pattern matching: mruby 4.0.0RC does not raise NoMatchingPatternError

1 participant