Tapioca does not generate RBI methods for Struct subclasses
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 873
- Forks
- 164
- Avg merge
- 4d 27m
- Merged PRs (30d)
- 9
Description
Pulling this out of the Sorbet Slack space and putting it here in case people are surprised by this and can find something about it.
I noticed this pattern in Faraday (ref https://github.com/lostisland/faraday/pull/1489 and https://github.com/lostisland/faraday/pull/1491):
class SSLOptions < Struct.new(:verify_hostname)
def verify?; end
end
tapioca gem generates RBI methods for verify? but not for verify_hostname/verify_hostname=. The Ruby docs recommend the block form to define a struct, which avoids creating an unused anonymous class in the ancestor chain:
SSLOptions = Struct.new(:verify_hostname) do
def verify?; end
end
which also happens to help Tapioca pick the verify_hostname/verify_hostname= methods.
It seems in https://github.com/Shopify/tapioca/pull/464 the intent was to fix this, but it seems to have been abandoned. IDK if this is still the plan or that people should just use the Style/StructInheritance Rubocop to avoid the issue from occurring?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Struct subclass reproduction in the issue and review the abandoned Shopify/tapioca#464 change to understand the intended handling. Done means tapioca gem generates both verify_hostname and verify_hostname= for the subclass, while preserving the existing verify? method output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100