From: "jeremyevans0 (Jeremy Evans)" Date: 2022-06-15T21:08:31+00:00 Subject: [ruby-core:108941] [Ruby master Bug#18832] Suspicious superclass mismatch Issue #18832 has been updated by jeremyevans0 (Jeremy Evans). fxn (Xavier Noria) wrote in #note-3: > Even more, if you set an autoload for `C` in `Object`, the autoload is triggered. Which is also consistent with "I have not found the constant in my lookup, but let's trigger the autoload to get it defined hopefully". This is also consistent. (And the autoload raises because it hits what the original example shows.) > > To me, this smells like a bug related to some quirk of the top-level object that is leaking. I agree that it would probably be best for things to be consistent. Note that this is not specifically related to top-level, but behavior of `Object` specifically, since it happens not just at top-level: ```ruby module M class C end end include M p Object.const_defined?(:C, false) class Object class C < String # still superclass mismatch end end ``` `Object` is treated specially during the lookup, that's probably where the difference comes from. ---------------------------------------- Bug #18832: Suspicious superclass mismatch https://bugs.ruby-lang.org/issues/18832#change-98029 * Author: fxn (Xavier Noria) * Status: Open * Priority: Normal * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- The following code: ```ruby module M class C end end include M p Object.const_defined?(:C, false) class C < String # (1) end ``` prints `false`, as expected, but then raises `superclass mismatch for class C (TypeError)` at (1). I believe this is a bug, because `Object` itself does not have a `C` constant, so (1) should just work, and the superclasse of `M::C` should be irrelevant. -- https://bugs.ruby-lang.org/ Unsubscribe: