mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user