diff --git a/lib/parser/prism/compiler.rb b/lib/parser/prism/compiler.rb index 4300ac0..8c9ef20 100644 --- a/lib/parser/prism/compiler.rb +++ b/lib/parser/prism/compiler.rb @@ -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 diff --git a/test/fixtures/and_asgn.rb b/test/fixtures/and_asgn.rb index a979265..964dc7e 100644 --- a/test/fixtures/and_asgn.rb +++ b/test/fixtures/and_asgn.rb @@ -1,3 +1,5 @@ foo.a &&= 1 foo[0, 1] &&= 2 + +$foo &&= 1 diff --git a/test/fixtures/op_asgn.rb b/test/fixtures/op_asgn.rb index a5a28b1..bb078eb 100644 --- a/test/fixtures/op_asgn.rb +++ b/test/fixtures/op_asgn.rb @@ -3,3 +3,5 @@ foo.a += 1 foo::a += 1 + +$foo += 1 diff --git a/test/fixtures/or_asgn.rb b/test/fixtures/or_asgn.rb index 6e4ecc9..8d4122e 100644 --- a/test/fixtures/or_asgn.rb +++ b/test/fixtures/or_asgn.rb @@ -1,3 +1,5 @@ foo.a ||= 1 foo[0, 1] ||= 2 + +$foo ||= 1