Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #10 from takaram/fix-gvar-op-asgn
Browse files Browse the repository at this point in the history
Fix self assignment node with global vars
  • Loading branch information
kddnewton authored Jan 17, 2024
2 parents e0fc1c4 + 828457b commit 3259598
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/parser/prism/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ def visit_global_variable_write_node(node)
def visit_global_variable_operator_write_node(node)
builder.op_assign(
builder.assignable(builder.gvar(token(node.name_loc))),
[node.operator, srange(node.operator_loc)],
[node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
visit(node.value)
)
end
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/and_asgn.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
foo.a &&= 1

foo[0, 1] &&= 2

$foo &&= 1
2 changes: 2 additions & 0 deletions test/fixtures/op_asgn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
foo.a += 1

foo::a += 1

$foo += 1
2 changes: 2 additions & 0 deletions test/fixtures/or_asgn.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
foo.a ||= 1

foo[0, 1] ||= 2

$foo ||= 1

0 comments on commit 3259598

Please sign in to comment.