Skip to content

Commit

Permalink
- Builders::Default: "a&.b &&= c": fix safe navigation in lhs of op-a…
Browse files Browse the repository at this point in the history
…ssignment.
  • Loading branch information
iliabylich authored and whitequark committed Jul 19, 2016
1 parent 43a2d76 commit 1e8b1f9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/parser/builders/default.rb
Expand Up @@ -487,7 +487,7 @@ def assign(lhs, eql_t, rhs)

def op_assign(lhs, op_t, rhs)
case lhs.type
when :gvasgn, :ivasgn, :lvasgn, :cvasgn, :casgn, :send
when :gvasgn, :ivasgn, :lvasgn, :cvasgn, :casgn, :send, :csend
operator = value(op_t)[0..-1].to_sym
source_map = lhs.loc.
with_operator(loc(op_t)).
Expand Down
8 changes: 8 additions & 0 deletions test/test_parser.rb
Expand Up @@ -3436,6 +3436,14 @@ def test_send_block_conditional
ALL_VERSIONS - %w(1.8 1.9 2.0 2.1 2.2 ios mac))
end

def test_send_op_asgn_conditional
assert_parses(
s(:and_asgn, s(:csend, s(:send, nil, :a), :b), s(:int, 1)),
%q{a&.b &&= 1},
%q{},
ALL_VERSIONS - %w(1.8 1.9 2.0 2.1 2.2 ios mac))
end

def test_lvar_injecting_match
assert_parses(
s(:begin,
Expand Down

0 comments on commit 1e8b1f9

Please sign in to comment.