Two includes of superclass-nested modules leave both mixins and their constants unresolved
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
Research direction
Start by tracing how Rubydex resolves included modules and their constants in the fixed-point loop; the issue does not name implementation files or tests. Reproduce the example with two superclass-nested includes, then compare it with the working single-include case. Done means both mixin references and the constants read through them resolve, including when both includes appear on one line.
Written by the indexing model from the issue text.
Description
A class that includes two modules nested in its superclass's namespace leaves both mixins unresolved, and the constants read through them too. With a single include, everything resolves.
# shop.rb
class Shop
end
# rate_concept.rb
module Shop::RateConcept
LIMIT = 3
end
# price_concept.rb
module Shop::PriceConcept
CAP = 9
end
# synth.rb
class Shop::Synth < Shop
include RateConcept
include PriceConcept
def fetch = LIMIT + CAP
end
require "rubydex"
graph = Rubydex::Graph.new
graph.index_all(Dir.glob("*.rb"))
graph.constant_references do |r|
next if r.location.uri.start_with?("rubydex:")
puts "#{r.class.name.split('::').last} #{r.respond_to?(:name) ? r.name : r.declaration.name} #{r.location}"
end
With rubydex 0.4.4 (arm64-darwin, Ruby 4.0.9), the output is:
UnresolvedConstantReference RateConcept synth.rb:2:11-2:22
UnresolvedConstantReference PriceConcept synth.rb:3:11-3:23
UnresolvedConstantReference CAP synth.rb:5:23-5:26
UnresolvedConstantReference LIMIT synth.rb:5:15-5:20
UnresolvedConstantReference <LIMIT> synth.rb:5:15-5:20
ResolvedConstantReference Shop ...
Ruby finds each module through the superclass (Shop::RateConcept, then Shop::PriceConcept), and the method reads their constants:
$ ruby -e '...same code...; p Shop::Synth.ancestors.first(3), Shop::Synth.new.fetch'
[Shop::Synth, Shop::PriceConcept, Shop::RateConcept]
12
With only include RateConcept (and def fetch = LIMIT), the output is Shop::RateConcept and Shop::RateConcept::LIMIT, both resolved. It looks like the second mixin's resolution depends on the first one's being settled, and the fixed-point loop gives up on both instead of resolving them in order.
Writing include RateConcept, PriceConcept on one line gives the same result.
- 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
-
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 30 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
-
`resolve_constant` returns nil for names with three or more segmentsPossibly taken @vinistock claimed this 33 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 65/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