keygen-sh / typed_params

An alternative to Rails strong_parameters. Define structured and strongly-typed parameter schemas for your Rails controllers.
MIT License
112 stars 0 forks source link

Issue: Typed_params breaks on ruby 3.3.0 #6

Closed dylandamsma closed 8 months ago

dylandamsma commented 8 months ago

First of all, fantastic work on this gem. It's precisely what I was looking for to move fast in a very small rails + mobile team, without having to go back and forth on "What should the value be here?".

However, unfortunately found that the gem breaks on Ruby 3.3.0

../.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/typed_params-1.1.0/lib/typed_params/mapper.rb:58: anonymous block parameter is also used within block (SyntaxError)
../.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/typed_params-1.1.0/lib/typed_params/mapper.rb:60: anonymous block parameter is also used within block

Please see this change: https://rubyreferences.github.io/rubychanges/3.3.html#anonymous-parameters-forwarding-inside-blocks-are-disallowed

Unfortunately, I'm not so well versed myself in the problem/solution here, otherwise I'd have opened a PR, apologies 🙏

ezekg commented 8 months ago

This looks like a Ruby bug (already fixed and will be released in 3.3.1), since the blocks aren't actually defining anonymous blocks, but rather using the anonymous block defined in the top level method. But I'll fix here in the meantime since it's not a big deal. All we have to do is rename the & parameter to &block. I'm out of town, but will get a new release cut on or around the 1st, plus CI against Ruby 3.3.

ezekg commented 8 months ago

Fixed in v1.1.1.

dylandamsma commented 8 months ago

Really appreciate the reply and the fix as well as the explanation. I'll do my best to understand more!