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 <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-09-11 14:26:18 +09:00
parent 8967ad200a
commit 8c3de9c85e
+3 -2
View File
@@ -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;