`tapioca gem`: a method with an anonymous block + RBS-comment: compiled to invalid syntax
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 873
- Forks
- 164
- Avg merge
- 4d 27m
- Merged PRs (30d)
- 9
Description
If we add a test compiling the following code (to spec/tapioca/gem/pipeline_spec.rb):
class Foo
#: { -> void } -> void
def foo(&); end
end
the test will fail with
Tapioca::Gem::PipelineSpec::Tapioca::Gem::Pipeline
it compiles RBS signature for a method with ananymous block FAIL (0.36s)
Tapioca::Gem::Pipeline#compile should not have any unhandled errors reported.
Please either fix your changes to ensure no errors are reported, or explicity pass
in a custom `error_handler: ->(err) { ... }` to the `compile()` method to handle
expected errors.
.
Expected ["Unable to compile signature for method: Foo#foo\n Exception raised when loading signature: #<RuntimeError: The declaration for `foo` is missing parameter(s): &>\n"] to be empty.
spec/tapioca/gem/pipeline_spec.rb:61:in 'Tapioca::Gem::PipelineSpec#compile'
spec/tapioca/gem/pipeline_spec.rb:4907:in 'block (2 levels) in <class:PipelineSpec>'
Finished in 0.39466s
1 tests, 2 assertions, 1 failures, 0 errors, 0 skips
Buf if we try to generate an RBI-file for a gem with such method, we get a definition with invalid syntax, like
sig { params(_arg0: ).returns(T.untyped) }
def foo(&_arg0); end
Expected result signatures:
sig { params("&": T.proc.void).void }
def foo(&); end
or
sig { params(block: T.proc.void).void }
def foo(&block); end
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 reproduction in spec/tapioca/gem/pipeline_spec.rb, especially the test for compiling an RBS signature on a method with an anonymous block. Trace how the signature is compiled and how the RBI method parameters are generated. Done means the compile test reports no unhandled errors and generated RBI contains valid syntax with a proc block parameter, such as &block.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100