Project

General

Profile

Actions

Bug #14407

closed

defined? still returning true for top-level constant when referenced with scope

Added by grzuy (Gonzalo Rodriguez) over 6 years ago. Updated about 6 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:85142]

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


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #11547: remove top-level constant lookupClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0