Skip to content

Fix rbs inline signatures for attributes - #1826

Open
Earlopain wants to merge 1 commit into
ruby:masterfrom
Earlopain:rbs-for-attrs
Open

Earlopain wants to merge 1 commit into
ruby:masterfrom
Earlopain:rbs-for-attrs

Conversation

@Earlopain

Copy link
Copy Markdown
Contributor

They are only effective when on the same line like attr_reader :foo #: Bar

https://github.com/ruby/rbs/blob/6c775eec9b6f285a6921aa753f606cd4bcdc83ab/docs/inline.md#attributes

Copilot AI balanced review requested due to automatic review settings September 20, 2026 18:15
@github-actions

github-actions Bot commented Sep 20, 2026

Copy link
Copy Markdown

Documentation preview

View the preview

Commit: 54e5f4f

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Non-signature trailing comments are incorrectly treated as RBS signatures.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Updates Ruby attribute parsing to recognize RBS signatures only as trailing inline annotations.

Changes:

  • Reads attribute signatures from modifier comments.
  • Preserves preceding documentation comments.
  • Adds typed and untyped attribute coverage.
File Description
lib/​rdoc/​parser/​ruby.rb Extracts inline attribute type signatures.
test/​rdoc/​parser/​ruby_test.rb Tests attribute signatures and documentation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/rdoc/parser/ruby.rb

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Multiline attribute declarations silently lose valid trailing signatures because lookup uses the call’s start line.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)

Comment thread lib/rdoc/parser/ruby.rb Outdated
Copilot AI review requested due to automatic review settings September 20, 2026 18:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The focused parser change matches inline RBS attribute syntax and is adequately covered by tests.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)

Copilot AI review requested due to automatic review settings September 20, 2026 18:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Attribute validation incorrectly accepts method signatures that RBS rejects for attributes.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)

Comment thread lib/rdoc/parser/ruby.rb
Comment on lines +964 to +968
type_signatures_from([comment], line_no)
end

def type_signatures_from(sig_lines, first_sig_line)
sig_lines = sig_lines.map { |line| line.sub(RBS_SIG_LINE, '').strip }.reject(&:empty?)
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.

2 participants