Skip to content

Make TypeNameResolver more compatible with Ruby#1373

Merged
soutaro merged 1 commit into
masterfrom
type-name-resolver
Jul 13, 2023
Merged

Make TypeNameResolver more compatible with Ruby#1373
soutaro merged 1 commit into
masterfrom
type-name-resolver

Conversation

@soutaro
Copy link
Copy Markdown
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
Copy Markdown
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 force-pushed the type-name-resolver branch from ad83d4c to 4cfd7da Compare July 13, 2023 08:15
@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
@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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant