dry-rb / dry-schema

Coercion and validation for data structures
https://dry-rb.org/gems/dry-schema
MIT License
415 stars 108 forks source link

Fix Ruby 2.x.x keyword warnings when using argument forwarding #449

Closed bkuhlmann closed 1 year ago

bkuhlmann commented 1 year ago

Describe the bug

Hello. :wave: I'm seeing the following warnings when using Dry Schema with Ruby 3.2.0 RC1:

lib/dry/schema/macros/dsl.rb:181: warning: Skipping set of ruby2_keywords flag for array (method accepts keywords or method does not accept argument splat)

To Reproduce

The quickest way to reproduce is to install Ruby 3.2.0 RC1 using your favorite Ruby Version Manager or you can use my latest Docker image which is running Ruby 3.2.0 with YJIT. Then you can run the following code snippet:

#! /usr/bin/env ruby
# frozen_string_literal: true

# Save as `snippet`, then `chmod 755 snippet`, and run as `./snippet`.

require "bundler/inline"

gemfile true do
  source "https://rubygems.org"
  gem "dry-schema"
end

Demo = Dry::Schema.Params { required(:demo).filled :string }

Expected behavior

I'd like to not see the warnings being printed. To fix -- at least when tinkering locally -- I deleted ruby2_keywords lines from the following files to fix the problem:

lib/dry/schema/macros/dsl.rb
lib/dry/schema/macros/key.rb

Because Dry Schema is using argument forwarding, it would be simple enough to delete use of ruby2_keywords if you are willing to release a version that supports Ruby 3.2.0 or higher. It might be possible to use a minimum version of Ruby 3.1.x but not sure (have not tested on 3.1 or 3.0).

My environment

esparta commented 1 year ago

The issue was fixed on #447 and will be soon on the next release, @bkuhlmann .

bkuhlmann commented 1 year ago

Hey Espartaco, thanks! I was searching through issues and didn't see this mentioned but didn't search through closed pull requests. Good to know and looking forward to the next release. :bow: