summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-25 00:36:43 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-25 00:36:43 +0000
commit85143cab00f41efa2cc566cd6485a79c64bd9bf3 (patch)
tree2b9fd212e59659dc286dd8f8a30e33af39a9e3e5 /variable.c
parente16d49fbceb6b4359ca23b58a3c6d7abd4b80690 (diff)
merge revision(s) 62071: [Backport #14407]
defined? returns nil for toplevel constant lookup * variable.c (rb_const_defined_0): toplevel constant lookup has been removed, should return nil too. [ruby-core:85142] [Bug #14407] [Fix GH-1800] From: Gonzalo <grzuy0@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@62568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/variable.c b/variable.c
index 310ef74d13..52ea6b4cab 100644
--- a/variable.c
+++ b/variable.c
@@ -2515,6 +2515,11 @@ rb_const_defined_0(VALUE klass, ID id, int exclude, int recurse, int visibility)
if (ce->value == Qundef && !check_autoload_required(tmp, id, 0) &&
!rb_autoloading_value(tmp, id, 0))
return (int)Qfalse;
+
+ if (exclude && tmp == rb_cObject && klass != rb_cObject) {
+ return (int)Qfalse;
+ }
+
return (int)Qtrue;
}
if (!recurse) break;