Actions
Bug #13204
closedSearch order of constant is different
Description
class CleanRoom < BasicObject
def call
instance_eval(<<-CODE)
$stdout.puts ::ENV.size
CODE
end
def call2
instance_eval(<<-CODE)
$stdout.puts ENV.size
CODE
end
def call3
instance_eval { $stdout.puts ::ENV.size }
end
end
class CleanRoom2
def call
instance_eval(<<-CODE)
$stdout.puts ENV.size
CODE
end
end
CleanRoom.new.call # => 80 (in my environment)
CleanRoom2.new.call # => 80
CleanRoom.new.call3 # => 80
CleanRoom.new.call2 # => t.rb:14:in `instance_eval': uninitialized constant #<Class:#<CleanRoom:0x0055698d201da8>>::ENV (NameError)
CleanRoom
instance cannot refer constants defined in top level.
Is this intentional?
Updated by nobu (Nobuyoshi Nakada) about 7 years ago
- Status changed from Open to Closed
Intentional.
Top level constants are constants defined in Object
, but BasicObject
does not inherit Object
.
Updated by okkez (okkez _) about 7 years ago
Thank you for response!
Actions
Like0
Like0Like0