summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-27 06:12:09 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-27 06:12:09 (GMT)
commit9473f86fb0ca396adaccf151874604faf47d852e (patch)
treeaa99888eb1cc8acb0b35218de947279d4c3735d1 /variable.c
parent17d8433d276ecc041376e67fea5430df7e97fb21 (diff)
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/trunk@62071 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 3f9725a..c8fd155 100644
--- a/variable.c
+++ b/variable.c
@@ -2513,6 +2513,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;