sord: Some signatures are broken due to lack of module scoping

Describe the bug Because Sord does not nest modules and classes inside each other in the RBI files, module and class names must always be fully qualified.

To Reproduce

module Example
  class A; end

  class B
    # @return [A]
    def x
      # ...
    end
  end
end

Expected behavior Sorbet accepts this code.

Actual behavior Sorbet encounters a reference error because it cannot resolve A. If Example::A is used as B#x’s return type, such an error does not occur.

Additional information This will require arbitrarily deep nesting of modules and classes, and the RBI generator is not capable of handling the indentation for this. It may be best to generate the file with no indentation to begin with, then pass a beautifier over it. (This has the potential to kill two birds with one stone by implementing the parameter line breaking specified in #13.)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (18 by maintainers)

Most upvoted comments

I’m not sure - the output from Sorbet looks a bit fancier than what I’m used to seeing from the stdlib, off the top of my head. (I suppose they could still be using did_you_mean behind the scenes though.) I’ll look into it tomorrow.

On Sun, 23 Jun 2019, 02:07 Connor Shea, notifications@github.com wrote:

Do they literally just use the did_you_mean gem from the stdlib?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AaronC81/sord/issues/25?email_source=notifications&email_token=AAZK7LN547ZL47AAFKLCILLP33EFFA5CNFSM4H2XYIUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYKUJAY#issuecomment-504710275, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZK7LLQPHJNEXNBUBEOOITP33EFFANCNFSM4H2XYIUA .