Skip to content

Commit

Permalink
Implement Until Node locations
Browse files Browse the repository at this point in the history
  • Loading branch information
ydah committed Sep 22, 2024
1 parent e8ae7f4 commit 0207c76
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 4 additions & 3 deletions lib/ast_to_prism/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,7 @@ def convert_node(node, block: nil)
)
when :UNTIL
nd_cond, nd_body, nd_state = node.children
loc, keyword_loc, closing_loc = node.locations

if nd_state
flags = 0
Expand All @@ -974,11 +975,11 @@ def convert_node(node, block: nil)
Prism::UntilNode.new(
source, # source
flags, # flags
null_location, # keyword_loc
null_location, # closing_loc
location(keyword_loc), # keyword_loc
location(closing_loc), # closing_loc
convert_node(nd_cond), # predicate
convert_stmts(nd_body), # statements
location(node) # location
location(loc) # location
)
when :ITER
# example: 3.times { foo }
Expand Down
8 changes: 3 additions & 5 deletions spec/basic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1977,7 +1977,7 @@ def foo(a, b, opt1=1, opt2=2, *rest, y, z, kw: 1, **kwrest, &blk)

describe "until" do
it "tests" do
pending "keyword_loc and closing_loc are not supported"
pending "message_loc is not supported"

test_code(<<~CODE)
until x == 1 do
Expand All @@ -1987,7 +1987,7 @@ def foo(a, b, opt1=1, opt2=2, *rest, y, z, kw: 1, **kwrest, &blk)
end

it "tests" do
pending "keyword_loc and closing_loc are not supported"
pending "message_loc is not supported"

test_code(<<~CODE)
until x == 1
Expand All @@ -1999,13 +1999,11 @@ def foo(a, b, opt1=1, opt2=2, *rest, y, z, kw: 1, **kwrest, &blk)

describe "modifier until" do
it "tests" do
pending "keyword_loc and closing_loc are not supported"

test_code("foo until true")
end

it "tests" do
pending "keyword_loc and closing_loc are not supported"
pending "StatementNode with begin keyword is not supported"

test_code("begin foo end until true")
end
Expand Down

0 comments on commit 0207c76

Please sign in to comment.