From ee06bbb4177a0c65aab9b3006f0f15fe9f3503fd Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sun, 4 Jan 2026 15:16:03 +0900 Subject: [PATCH] vm.c: replace type assertions with runtime checks Replace mrb_assert with mrb_ensure_*_type for VM opcodes that require specific types: - OP_ARYCAT: mrb_ensure_array_type - OP_ARYPUSH: mrb_ensure_array_type - OP_ASET: mrb_ensure_array_type (also fixed: was checking wrong register) - OP_INTERN: mrb_ensure_string_type - OP_HASHCAT: mrb_ensure_hash_type These checks catch codegen bugs with clear error messages in both debug and release builds. Co-authored-by: Claude --- src/vm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/vm.c b/src/vm.c index ca86895bb..b3bb28a8b 100644 --- a/src/vm.c +++ b/src/vm.c @@ -3003,7 +3003,7 @@ RETRY_TRY_BLOCK: regs[a] = splat; } else { - mrb_assert(mrb_array_p(regs[a])); + mrb_ensure_array_type(mrb, regs[a]); mrb_ary_concat(mrb, regs[a], splat); } mrb_gc_arena_restore(mrb, ai); @@ -3011,7 +3011,7 @@ RETRY_TRY_BLOCK: } CASE(OP_ARYPUSH, BB) { - mrb_assert(mrb_array_p(regs[a])); + mrb_ensure_array_type(mrb, regs[a]); for (mrb_int i=0; ic->ci; mrb_gc_arena_restore(mrb, ai);