diff options
author | Jeremy Evans <code@jeremyevans.net> | 2019-08-13 22:44:36 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2019-08-14 09:50:14 -0700 |
commit | fbcd0652944568c43a6ae427960d909d62ce6a8d (patch) | |
tree | 5c81bdb7b8258c9bc00734c30b69a48c7502632c /compile.c | |
parent | 7d32cb7631677172d12010233432b7470046ec2a (diff) |
Remove support for nil::Constant
This was an intentional bug added in 1.9.
The approach taken here is to add a second operand to the
getconstant instruction for whether nil should be allowed and
treated as current scope.
Fixes [Bug #11718]
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -4404,18 +4404,18 @@ compile_const_prefix(rb_iseq_t *iseq, const NODE *const node, switch (nd_type(node)) { case NODE_CONST: debugi("compile_const_prefix - colon", node->nd_vid); - ADD_INSN1(body, nd_line(node), getconstant, ID2SYM(node->nd_vid)); + ADD_INSN2(body, nd_line(node), getconstant, ID2SYM(node->nd_vid), 1); break; case NODE_COLON3: debugi("compile_const_prefix - colon3", node->nd_mid); ADD_INSN(body, nd_line(node), pop); ADD_INSN1(body, nd_line(node), putobject, rb_cObject); - ADD_INSN1(body, nd_line(node), getconstant, ID2SYM(node->nd_mid)); + ADD_INSN2(body, nd_line(node), getconstant, ID2SYM(node->nd_mid), 1); break; case NODE_COLON2: CHECK(compile_const_prefix(iseq, node->nd_head, pref, body)); debugi("compile_const_prefix - colon2", node->nd_mid); - ADD_INSN1(body, nd_line(node), getconstant, ID2SYM(node->nd_mid)); + ADD_INSN2(body, nd_line(node), getconstant, ID2SYM(node->nd_mid), 0); break; default: CHECK(COMPILE(pref, "const colon2 prefix", node)); @@ -7154,7 +7154,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in ADD_INSNL(ret, line, branchunless, lassign); /* cref */ } ADD_INSN(ret, line, dup); /* cref cref */ - ADD_INSN1(ret, line, getconstant, ID2SYM(mid)); /* cref obj */ + ADD_INSN2(ret, line, getconstant, ID2SYM(mid), 1); /* cref obj */ if (node->nd_aid == idOROP || node->nd_aid == idANDOP) { lfin = NEW_LABEL(line); @@ -7500,13 +7500,13 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in int ic_index = body->is_size++; ADD_INSN2(ret, line, opt_getinlinecache, lend, INT2FIX(ic_index)); - ADD_INSN1(ret, line, getconstant, ID2SYM(node->nd_vid)); + ADD_INSN2(ret, line, getconstant, ID2SYM(node->nd_vid), 1); ADD_INSN1(ret, line, opt_setinlinecache, INT2FIX(ic_index)); ADD_LABEL(ret, lend); } else { ADD_INSN(ret, line, putnil); - ADD_INSN1(ret, line, getconstant, ID2SYM(node->nd_vid)); + ADD_INSN2(ret, line, getconstant, ID2SYM(node->nd_vid), 1); } if (popped) { @@ -7893,7 +7893,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in } ADD_INSN1(ret, line, putobject, rb_cObject); - ADD_INSN1(ret, line, getconstant, ID2SYM(node->nd_mid)); + ADD_INSN2(ret, line, getconstant, ID2SYM(node->nd_mid), 1); if (ISEQ_COMPILE_DATA(iseq)->option->inline_const_cache) { ADD_INSN1(ret, line, opt_setinlinecache, INT2FIX(ic_index)); |