Skip to content

Unexpected errors when specifying method signatures in RBS and returning values with return #377

@whtsht

Description

@whtsht

Case 1
No error is expected, but the following error is reported:

#: (String) -> bool
def a(a)
  return false #=> [error] expected: bool; actual: bot
end

Suppressing the error in Case 1 is relatively straightforward. whtsht@c0e142e
However, as noted in the comment, this appears to be more of a workaround than a proper fix.

For example, Case 2 cannot be resolved by the same adjustment used for Case 1.


Case 2
No error is expected, but the following error is reported:

#: (bool) -> String | Integer
def foo(a)
  if a
    "true"
  else
    return 0 # => [error] expected: String; actual: Integer
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions