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

Singleton does not have method instance #1498

Open
mschoenlaub opened this issue Sep 4, 2023 · 1 comment
Open

Singleton does not have method instance #1498

mschoenlaub opened this issue Sep 4, 2023 · 1 comment

Comments

@mschoenlaub
Copy link

Typechecking for singletons (the pattern) doesn't seem to work as expected.

E.g. given an rb file

# frozen_string_literal: true
require "singleton"

module A
  module Example
    class TestClass
      include Singleton
    end
  end
end

A::Example::TestClass.instance

and and RBS file:

module A
  module Example
    VERSION: String

    class TestClass
      include Singleton
    end
  end
end

steep complains about: Type singleton(::A::Example::TestClass) does not have method instance.

The simples possible Steepfile i could come up with for the repro case:

 target :lib do
    signature "sig"
    check "lib"
    library "singleton"
 end

Given that there are some moving parts involved but also there's still active development going on, I wonder whether this supposed to even work right now?

In the original project The class including Singleton also extends Forwardable and so i was somehow hoping that it's just some weirdness. But even in this simple repro case it just doesn't work as expected.

@nogweii
Copy link

nogweii commented Oct 26, 2023

I'm also running into this, and I can fix it by adding the following additional signature:

module A
  module Example
    class TestClass
      def self.instance: () -> singleton(A::Example::TestClass)
    end
  end
end

But then I get a new error:

Type `singleton(::A::Example::TestClass)` does not have method `example`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants