summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-08-13 22:44:36 -0700
committerJeremy Evans <code@jeremyevans.net>2019-08-14 09:50:14 -0700
commitfbcd0652944568c43a6ae427960d909d62ce6a8d (patch)
tree5c81bdb7b8258c9bc00734c30b69a48c7502632c /vm_insnhelper.c
parent7d32cb7631677172d12010233432b7470046ec2a (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 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index cc38a0dc4b..1b985f4e8d 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -890,12 +890,12 @@ vm_get_iclass(rb_control_frame_t *cfp, VALUE klass)
}
static inline VALUE
-vm_get_ev_const(rb_execution_context_t *ec, VALUE orig_klass, ID id, int is_defined)
+vm_get_ev_const(rb_execution_context_t *ec, VALUE orig_klass, ID id, int allow_nil, int is_defined)
{
void rb_const_warn_if_deprecated(const rb_const_entry_t *ce, VALUE klass, ID id);
VALUE val;
- if (orig_klass == Qnil) {
+ if (orig_klass == Qnil && allow_nil) {
/* in current lexical scope */
const rb_cref_t *root_cref = vm_get_cref(ec->cfp->ep);
const rb_cref_t *cref;
@@ -3146,7 +3146,7 @@ vm_defined(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, rb_num_t op_
}
case DEFINED_CONST:
klass = v;
- if (vm_get_ev_const(ec, klass, SYM2ID(obj), 1)) {
+ if (vm_get_ev_const(ec, klass, SYM2ID(obj), 1, 1)) {
expr_type = DEFINED_CONST;
}
break;