Dry-transaction keyword parameters in match blocks in Ruby 3.0

I can not use keyword parameters in dry-transaction match blocks in Ruby 3.0.

This code sample works on Ruby 2.7 but returns an error on 3.0:

require "dry/transaction"

class DoSomething
  include Dry::Transaction

  step :run

  private

  def run
    Success(a: 1, b: 2)
  end
end


DoSomething.new.call do |m|
  m.success { |a:, b:| puts "#{a}#{b}" }
  m.failure {}
end

Exception raised:
ArgumentError: missing keywords: :a, :b

From what I understand keyword parameters in Ruby 3.0 should be passed with a double splat operator and maybe that’s the problem?
https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/#typical-cases

Or am I doing something wrong?

I don’t think this will work on ruby 3.0, it was an intentional breaking change. It’s not reliable to pass hash values as keywords to a handling block either so the only option is changing your code.

Ok, thanks for the response!

If you’re running Ruby 3.0, then the pattern-matching basically makes dry-matcher obsolete

case DoSomething.new.call
in Success(a:, b:)
  puts "#{a}#{b}"
in Failure(err)
  # handle err
end