Skip to content

Commit

Permalink
Implement AliasGlobalVariable Node locations
Browse files Browse the repository at this point in the history
  • Loading branch information
ydah committed Sep 21, 2024
1 parent e8ae7f4 commit dbf36f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/ast_to_prism/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2039,14 +2039,15 @@ def convert_node(node, block: nil)
)
when :VALIAS
nd_alias, nd_orig = node.children
loc, keyword_loc = node.locations

# (source, new_name, old_name, keyword_loc, location)
Prism::AliasGlobalVariableNode.new(
source,
Prism::GlobalVariableReadNode.new(source, nd_alias, null_location),
Prism::GlobalVariableReadNode.new(source, nd_orig, null_location),
null_location,
location(node)
location(keyword_loc),
location(loc),
)
when :UNDEF
# TODO: Change original node structures
Expand Down
4 changes: 3 additions & 1 deletion spec/basic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2082,7 +2082,9 @@ def foo(a, b, opt1=1, opt2=2, *rest, y, z, kw: 1, **kwrest, &blk)
end

describe "valias" do
xit "tests" do
pending "Occur NoMethodError: undefined method '>>' for nil"

it "tests" do
test_code("alias $y $x")
end
end
Expand Down

0 comments on commit dbf36f0

Please sign in to comment.