Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorbet does not detect the non-existence of the "sig" method #3068

Closed
alexevanczuk opened this issue May 20, 2020 · 3 comments
Closed

Sorbet does not detect the non-existence of the "sig" method #3068

alexevanczuk opened this issue May 20, 2020 · 3 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@alexevanczuk
Copy link
Contributor

Input

→ View on sorbet.run

# typed: strict
class A
  sig { returns(String)}
  def bar
    'test'
  end
end

A.new.bar

Observed output

No errors! Great job

Expected behavior

Sorbet should say:


editor.rb:3: Method sig does not exist on T.class_of(A) https://srb.help/7003
     3 |  sig { returns(String)}
          ^^^^^^^^^^^^^^^^^^^^^^^
    https://github.com/sorbet/sorbet/tree/master/rbi/core/kernel.rbi#L554: Did you mean: Kernel#send?
     554 |  def send(arg0, *arg1, &blk); end
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^

Context

Context from slack:

  1. https://sorbet-ruby.slack.com/archives/CJL5B3CEN/p1589999692123900
  2. https://sorbet-ruby.slack.com/archives/CHN2L03NH/p1590000596388800
@alexevanczuk alexevanczuk added bug Something isn't working unconfirmed This issue has not yet been confirmed by the Sorbet team labels May 20, 2020
@jez jez removed the unconfirmed This issue has not yet been confirmed by the Sorbet team label May 20, 2020
@jez
Copy link
Collaborator

jez commented May 20, 2020

#2836 introduced this regression.

@jez jez added the good first issue Good for newcomers label May 20, 2020
@jez
Copy link
Collaborator

jez commented May 20, 2020

A potential solution would be to instead translate all sigs to an intrinsic like

sig(...) {...}

# becomes

<Magic>.sig(self, ...) {...}

and then to have special handling in calls.cc to ensure that if we ever did see such a <Magic>.sig call, that sig must be a valid method on self when given the same args.

@marianosimone
Copy link
Collaborator

This was fixed in #3083

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants