Inline support on protoype
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
Research direction
The reproduction uses lib/calculator.rb and bin/rbs prototype rb, with output in sig/lib/calculator.rbs. Start by running that command and tracing the prototype path to see why the inline annotation remains a comment. Done means the generated signature uses Integer parameters and return type as shown.
Written by the indexing model from the issue text.
Description
I was hoping to use inline documentation to generate proper type signatures, but it doesn't seem to be working at the moment. I have a PR with everything set up to demonstrate here.
Here is the gist, though:
I expect that this calculator.rb file:
class Calculator
# @rbs (Integer, Integer) -> Integer
def add(a, b)
a + b
end
end
And after running this command:
bin/rbs prototype rb lib/calculator.rb > sig/lib/calculator.rbs
Would produce this sig/lib/calculator.rbs file:
class Calculator
def add: (Integer a, Integer b) -> Integer
end
But at the moment, it produces this:
class Calculator
# @rbs (Integer, Integer) -> Integer
def add: (untyped a, untyped b) -> untyped
end
All this with the current specs:
❯ ruby --version
ruby 3.2.7 (2025-02-04 revision 02ec315244) [arm64-darwin23]
❯ bundle info rbs
* rbs (4.0.0.dev.4 8a97819)
Summary: Type signature for Ruby.
Homepage: https://github.com/ruby/rbs
Source Code: https://github.com/ruby/rbs.git
Changelog: https://github.com/ruby/rbs/blob/master/CHANGELOG.md
Path: /Users/aemadrid/.local/share/mise/installs/ruby/3.2.7/lib/ruby/gems/3.2.0/bundler/gems/rbs-8a97819d4419
Is this something that is in the works but not quite ready?
- Dominant language
- Ruby
- Stars
- 2.2k
- Forks
- 263
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 64
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
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.
More from ruby/rbs
-
InlineParser: `@rbs @ivar` annotation is reported as unused unless it is the first thing in the class bodyPossibly taken @ksss claimed this 50 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
Maintainers usually reply within 1 day
Similar issues
-
bug f:request-creation professional
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
mysociety/alaveteli#9733 · 1 comment ·
Maintainers usually reply within 1 day
-
needs verification
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 13 days
-
🐛 bug 👩💻 équipe CE 🧑🏭 entreprises
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
betagouv/conseillers-entreprises#4808 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100