Skip to content
Merged
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
10 changes: 7 additions & 3 deletions lib/unparser/writer/binary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,13 @@ def symbol_name
end

def dispatch
left_emitter.write_to_buffer
write(' ', MAP.fetch(effective_symbol), ' ')
visit(right)
if node.type.eql?(:and) && left.type.equal?(:or)
emit_with(KEYWORD_TOKENS)
else
left_emitter.write_to_buffer
write(' ', MAP.fetch(effective_symbol), ' ')
visit(right)
end
end

private
Expand Down
10 changes: 10 additions & 0 deletions test/corpus/semantic/and.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,13 @@

if a...b and c...d
end

a and b and c
(a and b) and c
a and (b and c)
a and b or c
(a and b) or c
a and (b or c)
a or b and c
(a or b) and c
a or (b and c)
1 change: 1 addition & 0 deletions test/corpus/semantic/or.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a[:x] = b[:x] || c[:x] || d(:new)