From: "jeremyevans0 (Jeremy Evans)" Date: 2022-06-15T20:23:30+00:00 Subject: [ruby-core:108938] [Ruby master Bug#18832] Suspicious superclass mismatch Issue #18832 has been updated by jeremyevans0 (Jeremy Evans). I don't think this is a bug. `p Object.const_defined?(:C, false)` explicitly says you don't want to look into ancestors. However `class C` at top level will look into ancestors of Object (even `class Object::C` will). I don't believe Ruby has syntax for a class opening that doesn't look into ancestors. You would have to do something like: `Object::C = Class.new(String)`. Changing `class C < String` to ignore `Object::C` (i.e. `M::C`) is likely to break backwards compatibility significantly. ---------------------------------------- Bug #18832: Suspicious superclass mismatch https://bugs.ruby-lang.org/issues/18832#change-98026 * 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: