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

Type Elem must be re-declared in Bundler::EndpointSpecification #105

Open
panthomakos opened this issue Aug 7, 2019 · 9 comments
Open

Comments

@panthomakos
Copy link
Contributor

I am getting this error after updating sorbet-typed and I am unsure how to resolve the issue:

./sorbet/rbi/sorbet-typed/lib/bundler/all/bundler.rbi:1218: Type Elem declared by parent T.class_of(Gem::Specification) must be re-declared in T.class_of(Bundler::EndpointSpecification) https://srb.help/5036
    1218 |class Bundler::EndpointSpecification < Gem::Specification
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    https://github.com/sorbet/sorbet/tree/16d69282147e20e65490971bf2986ac6fa54de23/rbi/stdlib/gem.rbi#L207: Elem declared in parent here
     207 |class Gem::Specification < Gem::BasicSpecification
                ^^^^^^^^^^^^^^^^^^
@jasnow
Copy link
Contributor

jasnow commented Aug 7, 2019

What happens when you run this: srb rbi suggest-typed

@connorshea
Copy link
Contributor

It's really weird that the bundler.rbi would cause that but not cause it in sorbet-typed itself :/

@connorshea
Copy link
Contributor

Are you on the latest version of sorbet? I'm not seeing this error :?

@connorshea
Copy link
Contributor

Oh it seems to happen if you have the bundler.rbi set to strong or strict. It won't error if it's set to true.

@aisamanra
Copy link
Collaborator

We've temporarily reverted the change that caused this—that way, we can figure out what caused this situation to arise in the first place before re-merging the PR.

@connorshea
Copy link
Contributor

I'm still confused as to where the Elem is supposed to be coming from :?

Also, if you want to get rid of the gem.rbi in your project you'll need to delete it yourself. Sorbet doesn't seem to delete files if they're in sorbet-typed, it only overwrites existing files or adds them.

@connorshea
Copy link
Contributor

ok, so it looks like Gem::Specification does indeed extend Enumerable in hidden.rbi, which would be why there's an issue that CI didn't pick up, because CI doesn't generate any hidden definitions.

class Gem::Specification
  extend ::Enumerable
end

So when I removed the explicit extend Enumerable for Specification in #92, it fixed the problem in CI but not when actually using Sorbet.

@connorshea
Copy link
Contributor

hm, actually this might happen regardless of whether gem.rbi is there? It seems to be entirely dependent on the typing level of bundler.rbi. So this problem is probably just caused by bundle exec srb rbi sorbet-typed not also running suggest-typed. At least, kind of.

@panthomakos
Copy link
Contributor Author

Running suggest-typed downgrades the file to typed: true and resolves the issue. It seems as though that file should be able to have a higher strictness though?

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

No branches or pull requests

4 participants