Actions
Bug #14407
closeddefined? still returning true for top-level constant when referenced with scope
Description
class A
end
class B
end
if defined?(A::B)
puts "defined"
puts A::B
else
puts "not defined"
end
When running this script with ruby 2.5.0 i get:
defined
Traceback (most recent call last):
test.rb:10:in `<main>': uninitialized constant A::B (NameError)
Did you mean? B
while my expectation was that after the top-level constant lookup was removed from ruby 2.5, defined? would return false and i would actually get
not defined
as output
Updated by grzuy (Gonzalo Rodriguez) almost 7 years ago
Related to https://bugs.ruby-lang.org/issues/11547
Updated by nobu (Nobuyoshi Nakada) almost 7 years ago
- Status changed from Open to Closed
Applied in changeset trunk|r62071.
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
Updated by nobu (Nobuyoshi Nakada) over 6 years ago
- Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN to 2.3: DONTNEED, 2.4: DONTNEED, 2.5: REQUIRED
Updated by naruse (Yui NARUSE) over 6 years ago
- Backport changed from 2.3: DONTNEED, 2.4: DONTNEED, 2.5: REQUIRED to 2.3: DONTNEED, 2.4: DONTNEED, 2.5: DONE
ruby_2_5 r62568 merged revision(s) 62071.
Updated by Eregon (Benoit Daloze) over 2 years ago
- Related to Feature #11547: remove top-level constant lookup added
Actions
Like0
Like0Like0Like0Like0Like0