From: "fxn (Xavier Noria)" Date: 2022-06-15T21:49:40+00:00 Subject: [ruby-core:108942] [Ruby master Bug#18832] Suspicious superclass mismatch Issue #18832 has been updated by fxn (Xavier Noria). You're right, it happens too if the first element of the nesting is `Object`. For context, this happened in a Rails application that had `app/models/comment.rb`, which worked regularly fine. However, in a `.rake` file the project had `include REXML` at the top-level and in Rake tasks the application could no longer define the `Comment` model due to the superclass mismatch. REXML [documents](https://github.com/ruby/rexml) such top-level include. This is debatable, but cannot distract from discussing the consistency of the pure lookup logic. If `Object` does not have `Comment`, I expect `class Comment; end` to define a new class, as in any other "namespace". ---------------------------------------- Bug #18832: Suspicious superclass mismatch https://bugs.ruby-lang.org/issues/18832#change-98030 * 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: