Aliasing `.new` doesn't reuse the signature from `#initialize`
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 873
- Forks
- 164
- Avg merge
- 4d 27m
- Merged PRs (30d)
- 9
Description
I'm running into this with the money gem:
# .rb
class Money
class << self
alias_method :from_cents, :new
end
def initialize( obj, currency = Money.default_currency, options = {})
# ...
end
end
# generated .rbi
class Money
# source://money//lib/money/money.rb#341
def initialize(obj, currency = T.unsafe(nil), options = T.unsafe(nil)); end
class << self
def from_cents(*_arg0); end
end
end
Also note that no source:// pointer comment is generated for the .new alias.
I get that technically you could override both .new and #initialize to have different signatures, but I'd be surprised if that's a common pattern. AFAICT Sorbet uses #initialize's signature to validate calls to .new.
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 Tapioca's RBI generation path for Ruby singleton method aliases, using the Money example and its generated .rbi as the reproduction. Compare the alias from_cents with initialize and check the missing source:// pointer; done means the alias reuses the initializer signature and includes the expected source pointer.
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
- 45/100