From 4982997b04c73c83dff8f67c10d9a0951837ecb4 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Wed, 8 Oct 2025 23:15:01 +0900 Subject: [PATCH] mruby-compiler: fix colon3 constant lookup; fix #6635, #6636 The bug was in codegen_colon3 which used genop_2(OP_OCLASS, sym) treating OCLASS as BB format, but OCLASS is B format that only loads ::Object without a symbol parameter. The fix uses the correct two-instruction pattern: OCLASS to load Object class, then GETMCNST to retrieve the constant from it. Co-authored-by: Claude --- mrbgems/mruby-compiler/core/codegen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index dbfd1e65b..8b5c92ba0 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -5271,9 +5271,9 @@ static void codegen_colon3(codegen_scope *s, node *varnode, int val) { struct mrb_ast_colon3_node *n = (struct mrb_ast_colon3_node*)varnode; - // Generate COLON3 (::Name) access manually int sym = new_sym(s, n->name); - genop_2(s, OP_OCLASS, cursp(), sym); + genop_1(s, OP_OCLASS, cursp()); + genop_2(s, OP_GETMCNST, cursp(), sym); if (val) push(); }