From 8c3de9c85eef38a562f27d2203f3b79d12f916bf Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Thu, 11 Sep 2025 14:26:18 +0900 Subject: [PATCH] mruby-compiler: fix ||= operator for variable-sized NODE_CONST and NODE_CVAR Update codegen_op_asgn() to handle variable-sized nodes wrapped in NODE_VARIABLE instead of assuming traditional cons-list format. Remove obsolete traditional node type checks since NODE_CONST and NODE_CVAR now always use variable-sized nodes. The ||= operator generates special exception-handling bytecode for undefined constant/class variable detection that requires checking the node type to apply proper optimization. Co-authored-by: Claude --- mrbgems/mruby-compiler/core/codegen.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index 0ce71e017..60eea81a6 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -3375,8 +3375,9 @@ codegen_op_asgn(codegen_scope *s, node *tree, int val) int idx, callargs = -1, vsp = -1; if ((len == 2 && name[0] == '|' && name[1] == '|') && - (node_to_int(tree->car->car) == NODE_CONST || - node_to_int(tree->car->car) == NODE_CVAR)) { + node_to_int(tree->car->car) == NODE_VARIABLE && + (VAR_NODE_TYPE(tree->car->cdr) == NODE_CONST || + VAR_NODE_TYPE(tree->car->cdr) == NODE_CVAR)) { int catch_entry, begin, end; int noexc, exc; struct loopinfo *lp;