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 <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-10-08 23:15:01 +09:00
parent 01091984e7
commit 4982997b04
+2 -2
View File
@@ -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();
}