Permalink
Browse files

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

  • Loading branch information...
matz committed Mar 23, 2016
1 parent 4fcff34 commit 1ce471c1cc8d19035b9b5f4eca17468850c07c69
Showing with 3 additions and 4 deletions.
  1. +3 −4 mrbgems/mruby-compiler/core/parse.y
@@ -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) */

0 comments on commit 1ce471c

Please sign in to comment.