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

This commit is contained in:
Yukihiro "Matz" Matsumoto
2016-03-24 07:59:58 +09:00
parent 4fcff34747
commit 1ce471c1cc
+3 -4
View File
@@ -709,14 +709,13 @@ new_masgn(parser_state *p, node *a, node *b)
static node*
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, "||") &&
((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);
}
else {
return list4((node*)NODE_OP_ASGN, a, nsym(op), b);
}
return n;
}
/* (:int . i) */