Skip to content

Commit

Permalink
||= with cvars and constants should work with false values; #3138
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Mar 23, 2016
1 parent 4fcff34 commit 1ce471c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions mrbgems/mruby-compiler/core/parse.y
Expand Up @@ -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) */
Expand Down

0 comments on commit 1ce471c

Please sign in to comment.