diff options
author | Dylan Thacker-Smith <Dylan.Smith@shopify.com> | 2019-11-06 01:47:32 -0500 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-11-13 15:36:58 +0900 |
commit | ac112f2b5dc7e16ccde8f048be80946187a033b0 (patch) | |
tree | 5ad84ea663becd04e7a77fd6f6cf5f4ea3678a86 /compile.c | |
parent | a5b6d7bca84fce6e13c68e8753893c4697960e3a (diff) |
Avoid top-level search for nested constant reference from nil in defined?
Fixes [Bug #16332]
Constant access was changed to no longer allow top-level constant access
through `nil`, but `defined?` wasn't changed at the same time to stay
consistent.
Use a separate defined type to distinguish between a constant
referenced from the current lexical scope and one referenced from
another namespace.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2657
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -4728,13 +4728,13 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, ADD_INSN3(ret, line, defined, (rb_is_const_id(node->nd_mid) ? - INT2FIX(DEFINED_CONST) : INT2FIX(DEFINED_METHOD)), + INT2FIX(DEFINED_CONST_FROM) : INT2FIX(DEFINED_METHOD)), ID2SYM(node->nd_mid), needstr); return; case NODE_COLON3: ADD_INSN1(ret, line, putobject, rb_cObject); ADD_INSN3(ret, line, defined, - INT2FIX(DEFINED_CONST), ID2SYM(node->nd_mid), needstr); + INT2FIX(DEFINED_CONST_FROM), ID2SYM(node->nd_mid), needstr); return; /* method dispatch */ @@ -7493,7 +7493,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in if (node->nd_aid == idOROP) { lassign = NEW_LABEL(line); ADD_INSN(ret, line, dup); /* cref cref */ - ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_CONST), + ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_CONST_FROM), ID2SYM(mid), Qfalse); /* cref bool */ ADD_INSNL(ret, line, branchunless, lassign); /* cref */ } |