From: nobu@... Date: 2017-02-10T04:31:03+00:00 Subject: [ruby-dev:49980] [Ruby trunk Bug#13204][Closed] Search order of constant is different Issue #13204 has been updated by Nobuyoshi Nakada. Status changed from Open to Closed Intentional. Top level constants are constants defined in `Object`, but `BasicObject` does not inherit `Object`. ---------------------------------------- Bug #13204: Search order of constant is different https://bugs.ruby-lang.org/issues/13204#change-62942 * Author: okkez _ * Status: Closed * Priority: Normal * Assignee: * Target version: * ruby -v: * Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN ---------------------------------------- ```ruby 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 #>::ENV (NameError) ``` `CleanRoom` instance cannot refer constants defined in top level. Is this intentional? -- https://bugs.ruby-lang.org/