fables-tales/rubyfmt

Wrong correction on trailing comma in block argument list

Opened this issue · 0 comments

  • Ruby version: ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22]
  • Rubyfmt git sha:
$ rubyfmt --version
rubyfmt-main 0.9.5

Input file

foo = [[1, 2], [3, 4]]
foo.each do |bar,|
  p(bar)
end

Rubyfmt's output

foo = [[1, 2], [3, 4]]
foo.each do |bar|
  p(bar)
end

This breaks because

With the block argument list |bar,|, the value of bar inside the block will be 1 and 3.
With the block argument list |bar|, the value of bar inside the block will be [1, 2] and [3, 4].