module Mod1
module Sub
end
end
module Mod2
include Mod1
end
module Mod3
include Mod2
include Sub
# 'Mod1::Sub' is included, but RDoc thinks unknown constant 'Sub' is included
end
What was wrong with constant lookup implementation
module M1
module M2
include A
include B
# Constant lookup of C
# should search under M2, under M1, recursively B, recursively A, recursively Object
# Was searching under M2, under B, under A, under M1
include C
include D
end
end
# To check constant lookup priority, comment out C=1, C=2, C=3.0, C=3.1, ... in that order
module A; C=4.0; module AA; C=4.1; end; include AA; end
module B; C=3.0; module BB; C=3.1; end; include BB; end
module X; C=:never; end
C=5.0; module O1; C=6.1; end; include O1 # TopLevel ≒ Object
class Object; C=5.1; module O2; C=6.0; end; include O2; end
module M1
include X
C=2
module M2
C=1
include A
include B
p C
end
end
Fixes this bug
What was wrong with constant lookup implementation
Ruby's actual constant priority document https://docs.ruby-lang.org/ja/latest/doc/spec=2fvariables.html#prio (Sorry, can't find the english version)