AaronC81 / sord

Convert YARD docs to Sorbet RBI and Ruby 3/Steep RBS files
https://sord.aaronc.cc
MIT License
299 stars 18 forks source link

Resolving ::<ClassName> in unpredictable #132

Closed yratanov closed 2 years ago

yratanov commented 2 years ago

Describe the bug Resolving ::<ClassName> in unpredictable

To Reproduce

In some cases, if I have User class also defined in some other module, it will be wrongly resolved.

# file user.rb

class User 
end

# file nested/user.rb

module Nested
  class User 
  end
end

# file something.rb

class Something
   # @param user [::User]
  def initialize(user:)
  end
end
# sord warn - ::User wasn't able to be resolved to a constant in this project
 def initialize: (user: Nested::User)

in other cases it returns this:

# sord warn - ::User wasn't able to be resolved to a constant in this project
 def initialize: (user: ::User)

But warning is still raised

Expected behavior

Actual behavior A description of what actually happened. Please post any incorrectly-generated RBI signatures, as well as the command-line output of Sord.

Additional information Add any other information about the problem here.

AaronC81 commented 2 years ago

Hi @yratanov, thanks for reporting this - I've opened a PR which I think should fix it.

If you get a chance, it'd be great if you could test this on your codebase where you initially saw the issue - thanks :)

yratanov commented 2 years ago

@AaronC81 Thank you! It works with your change! :)