From: "fxn (Xavier Noria)" Date: 2022-06-17T10:08:53+00:00 Subject: [ruby-core:108980] [Ruby master Bug#18832] Suspicious superclass mismatch Issue #18832 has been updated by fxn (Xavier Noria). A good exercise is to try to document this (all lookups should be documented). Something like: > In the `class/module` keywords, the constant is checked in the cref. If present, the object is retrieved. If it is a class/module respectively, reopened, otherwise, error condition. In the case of `Object`, ancestors are checked also and the object reopened if found because... WHY? Does the team believe this documentation makes sense? ---------------------------------------- Bug #18832: Suspicious superclass mismatch https://bugs.ruby-lang.org/issues/18832#change-98085 * 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: