Support custom members of Data class and Struct class#183
Open
tk0miya wants to merge 3 commits intosoutaro:mainfrom
Open
Support custom members of Data class and Struct class#183tk0miya wants to merge 3 commits intosoutaro:mainfrom
tk0miya wants to merge 3 commits intosoutaro:mainfrom
Conversation
Data class can define custom members via block:
```ruby
Measure = Data.define(:amount, :unit) do
def <=>(other)
return unless other.is_a?(self.class) && other.unit == unit
amount <=> other.amount
end
include Comparable
end
```
This generates type definitions for these custom members.
ref: https://ruby-doc.org/3.4.1/Data.html
tk0miya
pushed a commit
to tk0miya/rubocop-rbs_inline
that referenced
this pull request
Feb 21, 2026
Links to soutaro/rbs-inline#183 which adds support for custom members in Data.define and Struct.new blocks. https://claude.ai/code/session_018NGR1GYyr9VMLScVdNabAh
tk0miya
pushed a commit
to tk0miya/rubocop-rbs_inline
that referenced
this pull request
Feb 21, 2026
RBS::Inline does not parse block contents in `Data.define` calls, so methods defined inside such blocks are not recognized for type checking. This new cop detects the pattern and guides users to use a separate `Data.define` call followed by a class reopening. This is a known limitation of RBS::Inline. See soutaro/rbs-inline#183 for the upstream fix. https://claude.ai/code/session_018NGR1GYyr9VMLScVdNabAh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Data class and Struct class can define custom members via block:
This generates type definitions for these custom members.
refs: