зеркало из https://github.com/github/ruby.git
[ruby/prism] Handle stovetop start in constant path fullname
https://github.com/ruby/prism/commit/3a216e63fe
This commit is contained in:
Родитель
ed50161bd6
Коммит
cfabe9c51c
|
@ -118,7 +118,7 @@ module Prism
|
|||
current = current.parent
|
||||
end
|
||||
|
||||
unless current.is_a?(ConstantReadNode)
|
||||
unless current.is_a?(ConstantReadNode) || current == nil
|
||||
raise DynamicPartsInConstantPathError, "Constant path contains dynamic parts. Cannot compute full name"
|
||||
end
|
||||
|
||||
|
|
|
@ -52,5 +52,16 @@ module Prism
|
|||
node = Prism.parse(source).value.statements.body.first
|
||||
assert_equal("Foo::Bar::Baz::Qux", node.lefts.first.full_name)
|
||||
end
|
||||
|
||||
def test_full_name_for_constant_path_with_stovetop_start
|
||||
source = <<~RUBY
|
||||
::Foo:: # comment
|
||||
Bar::Baz::
|
||||
Qux, Something = [1, 2]
|
||||
RUBY
|
||||
|
||||
node = Prism.parse(source).value.statements.body.first
|
||||
assert_equal("::Foo::Bar::Baz::Qux", node.lefts.first.full_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче