Skip to content

Don't let a bracketed comment in a class body drop its superclass - #1301

Open
apiology wants to merge 1 commit into
castwide:masterfrom
apiology:worktree-fix-1300-inline-rbs-superclass-scope
Open

Don't let a bracketed comment in a class body drop its superclass#1301
apiology wants to merge 1 commit into
castwide:masterfrom
apiology:worktree-fix-1300-inline-rbs-superclass-scope

Conversation

@apiology

Copy link
Copy Markdown
Contributor

Fixes #1300

An ordinary comment anywhere in a class body could silently remove that
class's superclass:

class Sub < Base
  # [:b, { c: :d }]

  def call_it
    greet   # Unresolved call to greet
  end
end

Every inherited method then reports Unresolved call, including on lines
above the comment, so the reported locations point nowhere near the cause.

parameters_from_inline_rbs regex-scanned the whole class body for #[...],
so any bracketed comment was read as the superclass's inline RBS type
arguments. # [:b, { c: :d }] yields the superclass name Base<:b, { c: :d,
which resolves to nothing.

The annotation is now only read where ruby/rbs's inline
syntax
defines it —
directly after the superclass, on the same line, #[ with no space — and a
closing ] is required.

Tightening worth noting: class Foo < Array # [String] (space after the #)
is now an ordinary comment rather than a type annotation.

Also removes a leftover debug logger.warn from
#1173.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NtwP1oKRXfJAbPQrPHm5oU

`parameters_from_inline_rbs` scanned the entire class body for
`#[...]`, so any bracketed comment in the body was read as the
superclass's type arguments. `# [:b, { c: :d }]` produced the
superclass name `Base<:b, { c: :d`, which resolves to nothing, and
every inherited method in the class then reported `Unresolved call` —
including on lines above the comment.

Match only where ruby/rbs's inline syntax puts it: directly after the
superclass, on the same line, `#[` with no space, with a closing `]`
required. `class Foo < Array # [String]` is now an ordinary comment.

Also removes a leftover debug `logger.warn` from
castwide#1173.

Fixes castwide#1300

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NtwP1oKRXfJAbPQrPHm5oU
apiology added a commit to apiology/solargraph that referenced this pull request Aug 15, 2026
@apiology
apiology marked this pull request as ready for review August 17, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unrelated comment removes superclass pin?

1 participant