fables-tales / rubyfmt

Ruby Autoformatter!
MIT License
1.07k stars 50 forks source link

Supporting Ruby 3.1 shorthand hash syntax #398

Closed maxjacobson closed 1 year ago

maxjacobson commented 1 year ago

Input file

a = 1
b = 2

h = { a:, b: }

puts h

Rubyfmt's output

Error! source: app.rb
Rubyfmt detected a syntax error in the ruby code being executed

This breaks because

This source code uses the new shorthand hash syntax introduced in Ruby 3.1 (more info: https://dev.to/baweaver/ruby-3-1-shorthand-hash-syntax-first-impressions-19op).

reese commented 1 year ago

I'm going to write up a meta-issue in a bit that tracks all the syntax we don't currently support (pattern matching, endless methods, this, etc.), but it's definitely on my radar. It does require us bumping the Ruby checkout pretty far though, so it'll be a bit just to make sure that doesn't totally bust anything.