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

Make TypeNameResolver more compatible with Ruby #1373

Merged
merged 1 commit into from
Jul 13, 2023
Merged

Conversation

soutaro
Copy link
Member

@soutaro soutaro commented Jul 13, 2023

No description provided.

@soutaro soutaro added this to the RBS 3.2 milestone Jul 13, 2023
manager.build do |env|
resolver = Resolver::TypeNameResolver.new(env)

assert_nil resolver.resolve(type_name("Foo::Bar"), context: [[nil, TypeName("::Foo")], TypeName("::Foo::Foo")])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It tried ::Foo::Foo::Foo::Bar, ::Foo::Foo::Bar, and ::Foo::Bar and resolved to ::Foo::Bar, but it was not how Ruby resolves constants.

With this PR, it tries only with the first component of given type name Foo as ::Foo::Foo::Foo and ::Foo::Foo, and resolves to ::Foo::Foo. Then it adds the tail part Bar as ::Foo::Foo::Bar, but it doesn't exist. So, it returns nil.

@soutaro soutaro added this pull request to the merge queue Jul 13, 2023
Merged via the queue into master with commit 3f0b99e Jul 13, 2023
23 checks passed
@soutaro soutaro deleted the type-name-resolver branch July 13, 2023 08:29
soutaro added a commit that referenced this pull request Jul 27, 2023
Make TypeNameResolver more compatible with Ruby
@soutaro soutaro added the Released PRs already included in the released version label Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Released PRs already included in the released version
Development

Successfully merging this pull request may close these issues.

1 participant