From: rick.hull@... Date: 2017-12-04T04:09:37+00:00 Subject: [ruby-core:84073] [Ruby trunk Bug#14148] Longstanding behavior regarding correspondence of toplevel with Object is surprising Issue #14148 has been updated by RickHull (Rick Hull). Hi @mame, I agree that the change from warning to NameError is intended, and this behavior change is not the concern: > I don't think is a problem for 2.5. The overall behavior seems consistent with 2.4, if surprising. My surprise mostly revolves around the strange correspondence of toplevel with Object. This bug report is not about the escalation of warning to NameError. When I first created this ticket, I was not aware of the "strange correspondence" between toplevel and Object, and the strange behavior resulting from this correspondence is now what this ticket is about. Again, this is longstanding behavior, so I do understand if there is no desire to change this behavior, and I certainly wouldn't suggest such a change for the 2.5 series. Maybe for Ruby 3. Again, I think this is a design bug or else a "wart". I apologize if the ticket is confusing and take all the credit for that :) The only connection to 2.5 and https://bugs.ruby-lang.org/issues/11547 at this point, is that I was studying ticket 11547 when I stumbled across the behavior I detailed above. Finally, as a side note, the proposal for 11547 seems ignorant of the correspondence between toplevel and Object, mirroring my own ignorance. I am sure @matz @nobu et al understand this correspondence implicitly, and this is why they expressed so much caution regarding the change, which, if the scope were truly limited to just toplevel and did not include Object constants, would be a "no-brainer". In all honesty, this ticket should probably be closed and maybe shifted to a mailing list discussion. But I will leave that in other, more capable hands. Cheers, Rick ---------------------------------------- Bug #14148: Longstanding behavior regarding correspondence of toplevel with Object is surprising https://bugs.ruby-lang.org/issues/14148#change-68164 * 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 `
': 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: