Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Index Operator Write Node locations #62

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions lib/ast_to_prism/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,7 @@ def convert_node(node, block: nil)
not_supported(node)
when :OP_ASGN1
nd_recv, nd_mid, nd_index, nd_rvalue = node.children
loc, call_operator_loc, opening_loc, closing_loc, binary_operator_loc = node.locations
receiver = convert_node(nd_recv)
arguments, _ = convert_arguments(nd_index)
# NOTE: Can block not be nil?
Expand All @@ -1250,18 +1251,18 @@ def convert_node(node, block: nil)
value = convert_node(nd_rvalue)

Prism::IndexOperatorWriteNode.new(
source, # source
0, # flags
receiver, # receiver
null_location, # call_operator_loc
null_location, # opening_loc
arguments, # arguments
null_location, # closing_loc
block, # block
binary_operator, # binary_operator
null_location, # binary_operator_loc
value, # value
location(node) # location
source, # source
0, # flags
receiver, # receiver
location(call_operator_loc), # call_operator_loc
location(opening_loc), # opening_loc
arguments, # arguments
location(closing_loc), # closing_loc
block, # block
binary_operator, # binary_operator
location(binary_operator_loc), # binary_operator_loc
value, # value
location(loc) # location
)
when :OP_ASGN2
nd_recv, nd_aid, nd_vid, nd_mid, nd_value = node.children
Expand Down
4 changes: 0 additions & 4 deletions spec/basic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -651,16 +651,12 @@ def test_code(code)

describe "array assignment with operator (OP_ASGN1)" do
it "tests" do
pending "IndexOperatorWriteNode locations are not supported"

test_code(<<~CODE)
ary[1] += foo
CODE
end

it "tests" do
pending "IndexOperatorWriteNode locations are not supported"

test_code(<<~CODE)
ary[1, 2] += foo
CODE
Expand Down
Loading