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
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v0.6.15 2024-06-10

[#373](https://github.com/mbj/unparser/pull/373)

* Fix additonal keyword dispatch

# v0.6.14 2024-06-10

[#369](https://github.com/mbj/unparser/pull/369)
Expand Down
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
unparser (0.6.14)
unparser (0.6.15)
diff-lcs (~> 1.3)
parser (>= 3.3.0)

Expand All @@ -12,14 +12,14 @@ GEM
diff-lcs (1.5.1)
json (2.7.2)
language_server-protocol (3.17.0.3)
mutant (0.12.2)
mutant (0.12.3)
diff-lcs (~> 1.3)
parser (~> 3.3.0)
regexp_parser (~> 2.9.0)
sorbet-runtime (~> 0.5.0)
unparser (~> 0.6.9)
mutant-rspec (0.12.2)
mutant (= 0.12.2)
unparser (~> 0.6.14)
mutant-rspec (0.12.3)
mutant (= 0.12.3)
rspec-core (>= 3.8.0, < 4.0.0)
parallel (1.25.1)
parser (3.3.2.0)
Expand Down
21 changes: 18 additions & 3 deletions lib/unparser/emitter/pair.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Pair < self
def dispatch
if colon?
emit_colon
unless implicit_value?
unless implicit_value_lvar? || implicit_value_send?
write(' ')
visit(value)
end
Expand All @@ -36,8 +36,23 @@ def emit_colon
write(key.children.first.to_s, ':')
end

def implicit_value?
n_lvar?(value) && value.children.first.equal?(key.children.first)
def key_value
key.children.first
end

def implicit_value_lvar?
n_lvar?(value) && value.children.first.equal?(key_value)
end

def implicit_value_send?
children = value.children

n_send?(value) \
&& !key_value.end_with?('?') \
&& !key_value.end_with?('!') \
&& children.fetch(0).nil? \
&& children.fetch(1).equal?(key_value) \
&& children.at(2).nil?
end
end
end
Expand Down
7 changes: 7 additions & 0 deletions test/corpus/literal/send.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,10 @@ def foo
a&.+(b)
a = nil
foo(bar: a)
foo(return:)
foo(bar: Bar.bar)
foo(bar: bar(1))
foo(bar: 1)
foo(do: true)
foo(a?: a?)
foo(a!: a!)
2 changes: 1 addition & 1 deletion unparser.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |gem|
gem.name = 'unparser'
gem.version = '0.6.14'
gem.version = '0.6.15'

gem.authors = ['Markus Schirp']
gem.email = 'mbj@schirp-dso.com'
Expand Down