8000 Inferred vs declared return type namespace mismatch · Issue #841 · castwide/solargraph · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Inferred vs declared return type namespace mismatch #841
Closed
@amake

Description

@amake

The following code:

module MyModule
  class Bar
    def initialize
      # empty
    end
  end

  class Baz
    # empty
  end

  class Foo1 < Bar
    class << self
      # This is an error
      #
      # @return [Foo1]
      def foo
        new
      end
    end
  end

  class Foo2 < Baz
    class << self
      # But this is not an error, and the only difference is whether the parent
      # class has an `initialize` method
      #
      # @return [Foo2]
      def foo
        new
      end
    end
  end
end

Gives the following error:

% solargraph typecheck --level typed tmp.rb
tmp.rb:17 - Declared return type MyModule::Foo1 does not match inferred type Foo1 for MyModule::Foo1.foo
1 problem found.

Changing line 17 to @return [MyModule::Foo1] resolves the issue, but it seems like that shouldn't be necessary or it should be required for line 28 (@return [Foo2]) as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0