`resolve_constant` returns nil for names with three or more segments
Maintainers usually reply within 1 day
@vinistock is already working on this.
Since Oct 21, 2026.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 65/100
Research direction
The report reproduces the failure with Graph#resolve_constant and shows that graph[...] can resolve the same fully qualified name. Start by locating the resolver implementation and its tests, then run the relevant tests and add coverage for names with three or more segments, including the nesting cases in the reproduction. Done when those calls return the declared constants without breaking the two-segment cases.
Written by the indexing model from the issue text.
Description
Graph#resolve_constant returns nil when the name has three or more segments. Two segments resolve fine, and so does the same constant if I move a segment into the nesting.
I ran into this through archspec, which resolves call receivers with resolve_constant. Every receiver like First::Second::Third.call comes back unresolved.
Repro:
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "rubydex", "0.4.1"
end
require "tmpdir"
Dir.mktmpdir do |dir|
path = File.join(dir, "example.rb")
File.write(path, <<~RUBY)
module A
module B
module C
class D; end
end
end
end
RUBY
graph = Rubydex::Graph.new
graph.index_all([path])
graph.resolve
[
["A::B", []],
["A::B::C", []],
["A::B::C::D", []],
["B::C", ["A"]],
["B::C::D", ["A"]],
["C::D", ["A", "B"]]
].each do |name, nesting|
puts "resolve_constant(#{name.inspect}, #{nesting.inspect}) => #{graph.resolve_constant(name, nesting)&.name.inspect}"
end
puts "graph[\"A::B::C::D\"] => #{graph["A::B::C::D"]&.name.inspect}"
end
Output:
resolve_constant("A::B", []) => "A::B"
resolve_constant("A::B::C", []) => nil
resolve_constant("A::B::C::D", []) => nil
resolve_constant("B::C", ["A"]) => "A::B::C"
resolve_constant("B::C::D", ["A"]) => nil
resolve_constant("C::D", ["A", "B"]) => "A::B::C::D"
graph["A::B::C::D"] => "A::B::C::D"
I expected every resolve_constant call above to return the declaration. It looks like a problem with how the name itself is resolved past its second segment, not with the nesting, but I have not dug into the resolver to confirm.
- Dominant language
- Rust
- Stars
- 382
- Forks
- 30
- Avg merge
- 16h 57m
- Merged PRs (30d)
- 10
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Shopify/rubydex
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
-
Constant reference unresolved inside a class nested in its own superclass when the outer namespace is only implied by compact definitionsPossibly taken @efegokdemir claimed this 29 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Maintainers usually reply within 1 day
-
`self.private :foo` is reported as an invalid visibility call and ignoredPossibly taken @RaphaelFakhri claimed this 30 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
Expose comment groups that aren't attached to a definitionPossibly taken @efegokdemir claimed this 31 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
-
Incorrect resolved superclass namePossibly taken @efegokdemir claimed this 38 days ago. Openbug roundhouse
Difficulty 4/5 1-2 days Newbie friendliness 25/100
Maintainers usually reply within 1 day
Similar issues
-
CI/CD ignore-for-release
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
eclipse-ankaios/ankaios#844 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
std: `SliceIndex<str>` missing for `std::ops` ranges, so generic `R: SliceIndex<str>` bounds failOpen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
symposium-dev/symposium#530 ·
Maintainers usually reply within 5 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day