`||=` with cvars and constants should work with false values; #3138

parent 4fcff347
...@@ -709,14 +709,13 @@ new_masgn(parser_state *p, node *a, node *b) ...@@ -709,14 +709,13 @@ new_masgn(parser_state *p, node *a, node *b)
static node* static node*
new_op_asgn(parser_state *p, node *a, mrb_sym op, node *b) new_op_asgn(parser_state *p, node *a, mrb_sym op, node *b)
{ {
node *n = list4((node*)NODE_OP_ASGN, a, nsym(op), b);
if (op == mrb_intern_lit(p->mrb, "||") && if (op == mrb_intern_lit(p->mrb, "||") &&
((intptr_t)a->car == NODE_CONST || (intptr_t)a->car == NODE_CVAR)) { ((intptr_t)a->car == NODE_CONST || (intptr_t)a->car == NODE_CVAR)) {
return new_rescue(p, a, list1(list3(list1(new_const(p, mrb_intern_lit(p->mrb, "NameError"))), return new_rescue(p, n, list1(list3(list1(new_const(p, mrb_intern_lit(p->mrb, "NameError"))),
0, new_asgn(p, a, b))), NULL); 0, new_asgn(p, a, b))), NULL);
} }
else { return n;
return list4((node*)NODE_OP_ASGN, a, nsym(op), b);
}
} }
/* (:int . i) */ /* (:int . i) */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment