Skip to content

Commit

Permalink
Handle { () => () } correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
mbj committed Jan 6, 2014
1 parent ee348be commit 9b237c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/unparser/emitter/begin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class Implicit < self

handle :begin

EMPTY_PARENS = [:pair_rocket].to_set.freeze

private

# Perform dispatch
Expand All @@ -34,7 +36,11 @@ class Implicit < self
# @api private
#
def dispatch
emit_inner
if children.empty? && EMPTY_PARENS.include?(parent_type)
write('()')
else
emit_inner
end
end

end # Implicit
Expand Down
1 change: 1 addition & 0 deletions spec/unit/unparser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ def self.assert_source(input, versions = RUBIES)

context 'hash' do
assert_source '{}'
assert_source '{ () => () }'
assert_source '{ 1 => 2 }'
assert_source '{ 1 => 2, 3 => 4 }'

Expand Down

0 comments on commit 9b237c1

Please sign in to comment.