Skip to content

tapioca gem: a method with an anonymous block + RBS-comment: compiled to invalid syntax #2663

Description

@Slike9

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions