Skip to content

Commit 98d2612

Browse files
committed
Fix constant lookup in contexts
1 parent f58333e commit 98d2612

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/rdoc/code_object/context.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -779,9 +779,8 @@ def find_class_method_named(name)
779779
# Finds a constant with +name+ in this context
780780

781781
def find_constant_named(name)
782-
@constants.find do |m|
783-
m.name == name || m.full_name == name
784-
end
782+
name = name[2..-1] if name.start_with?('::')
783+
@constants.find { |m| m.name == name || m.full_name == name }
785784
end
786785

787786
##

test/rdoc/rdoc_context_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ def test_find_class_method_named
524524
def test_find_constant_named
525525
assert_nil @c1.find_constant_named('NONE')
526526
assert_equal ':const', @c1.find_constant_named('CONST').value
527+
assert_equal ':const', @c1.find_constant_named('::CONST').value
527528
end
528529

529530
def test_find_enclosing_module_named

0 commit comments

Comments
 (0)