vm: add OP_MATCHERR instruction for pattern matching errors

Replace 4-instruction sequence (GETCONST + STRING + SEND + RAISEIF)
with single OP_MATCHERR instruction that raises NoMatchingPatternError
with "pattern not matched" message.

Bump RITE binary format version from 0300 to 0400 due to opcode
number shift.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2026-01-19 12:52:06 +09:00
parent 8c99e3dd29
commit 2fa99a73c2
5 changed files with 11 additions and 16 deletions
+4
View File
@@ -2167,6 +2167,10 @@ RETRY_TRY_BLOCK:
NEXT;
}
CASE(OP_MATCHERR, Z) {
RAISE_LIT(mrb, mrb_exc_get_id(mrb, MRB_ERROR_SYM(NoMatchingPatternError)), "pattern not matched");
}
CASE(OP_SSEND, BBB) {
regs[a] = regs[0];
}