Skip to content

Commit

Permalink
Merge pull request #54 from ydah/undef
Browse files Browse the repository at this point in the history
Implement Undef Node locations
  • Loading branch information
yui-knk authored Oct 2, 2024
2 parents e8ae7f4 + be15a71 commit efbc625
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions lib/ast_to_prism/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2052,6 +2052,7 @@ def convert_node(node, block: nil)
# TODO: Change original node structures

nd_undefs, = node.children
loc, keyword_loc = node.locations
names = nd_undefs.map do |node|
string, = node.children[0]
# TODO: Implement flags
Expand All @@ -2069,10 +2070,10 @@ def convert_node(node, block: nil)
end

Prism::UndefNode.new(
source, # source
names, # names
null_location, # keyword_loc
location(node), # location
source, # source
names, # names
location(keyword_loc), # keyword_loc
location(loc), # location
)
when :CLASS
# NOTE: In Prism ClassNode has locals but I think locals is a member of CLASS body stmts.
Expand Down
4 changes: 2 additions & 2 deletions spec/basic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2089,13 +2089,13 @@ def foo(a, b, opt1=1, opt2=2, *rest, y, z, kw: 1, **kwrest, &blk)

describe "undef" do
it "tests" do
pending "UndefNode keyword_loc is not supported"
pending "SymbolNode keyword_loc is not supported"

test_code("undef foo")
end

it "tests" do
pending "UndefNode keyword_loc is not supported"
pending "SymbolNode keyword_loc is not supported"

test_code("undef foo, :bar")
end
Expand Down

0 comments on commit efbc625

Please sign in to comment.