Issue #14148 has been updated by RickHull (Rick Hull).


Behavior on 2.4.0p0:

~~~ ruby
module Kernel
  X = 1
end

String::X #=> 1

X = 2

String::X #=> 2
# warning: toplevel constant X referenced by String::X
~~~

~~~ ruby
class Object
  X = 1
end

String.superclass #=> Object

String::X #=> 1
# warning: toplevel constant X referenced by String::X
~~~


----------------------------------------
Bug #14148: Ruby 2.5.0-preview1 - NameError on scoped constant after toplevel constant is defined
https://bugs.ruby-lang.org/issues/14148#change-68137

* Author: RickHull (Rick Hull)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.5.0preview1 (2017-10-10 trunk 60153) [x86_64-linux]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
~~~ ruby
module Kernel
  X = 1
end

puts String::X

X = 2

puts String::X
~~~

~~~
$ ruby test.rb
1
Traceback (most recent call last):
test.rb:9:in `<main>': uninitialized constant String::X (NameError)
Did you mean?  X

$ ruby --version
ruby 2.5.0preview1 (2017-10-10 trunk 60153) [x86_64-linux]
~~~



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>