Skip to content

Commit 3a216e6

Browse files
committed
Handle stovetop start in constant path fullname
1 parent bb9efce commit 3a216e6

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/prism/node_ext.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def full_name_parts
118118
current = current.parent
119119
end
120120

121-
unless current.is_a?(ConstantReadNode)
121+
unless current.is_a?(ConstantReadNode) || current == nil
122122
raise DynamicPartsInConstantPathError, "Constant path contains dynamic parts. Cannot compute full name"
123123
end
124124

test/prism/constant_path_node_test.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,16 @@ def test_full_name_for_constant_path_target
5252
node = Prism.parse(source).value.statements.body.first
5353
assert_equal("Foo::Bar::Baz::Qux", node.lefts.first.full_name)
5454
end
55+
56+
def test_full_name_for_constant_path_with_stovetop_start
57+
source = <<~RUBY
58+
::Foo:: # comment
59+
Bar::Baz::
60+
Qux, Something = [1, 2]
61+
RUBY
62+
63+
node = Prism.parse(source).value.statements.body.first
64+
assert_equal("::Foo::Bar::Baz::Qux", node.lefts.first.full_name)
65+
end
5566
end
5667
end

0 commit comments

Comments
 (0)