From: "Eregon (Benoit Daloze)" Date: 2022-06-16T17:13:02+00:00 Subject: [ruby-core:108964] [Ruby master Bug#18832] Suspicious superclass mismatch Issue #18832 has been updated by Eregon (Benoit Daloze). I agree we shouldn't look in modules prepended/included in Object, only look on the lexical parent itself (not its ancestors). This is one of these inconsistent "deep constant lookup" exceptions (the other I remember is "deepMethodSearch" used for `alias` and `public/protected/private`), I think we should fix it. @fxn I think it'd be useful if you show a Ruby code snippet of the real-world problem to motivate the change. FWIW, the logic in TruffleRuby to deal with that special case: https://github.com/oracle/truffleruby/blob/c99ec964fb51f8364c6919467e898db6969f4058/src/main/java/org/truffleruby/language/objects/LookupForExistingModuleNode.java#L63 https://github.com/oracle/truffleruby/blob/c99ec964fb51f8364c6919467e898db6969f4058/src/main/java/org/truffleruby/core/module/ModuleOperations.java#L202 ---------------------------------------- Bug #18832: Suspicious superclass mismatch https://bugs.ruby-lang.org/issues/18832#change-98065 * 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: