Skip to content

Conversation

@esposito
Copy link
Contributor

@esposito esposito commented Aug 2, 2023

In Ruby versions older than 3.2, objects that respond to #to_hash are always used to extract keyword arguments from when **kwargs is present in a method signature. It causes these objects to be passed in as a hash to the raise method instead of an object.

Code like raise CustomError, object_implementing_to_hash, which relies on object_implementing_to_hash to be an object, no longer works.

In this commit we ensure above code keeps working until keyword arguments are fixed in Ruby 3.2.

In Ruby versions older than 3.2, objects that respond to `#to_hash` are always used to extract keyword arguments from when `**kwargs` is present in a method signature. It causes these objects to be passed in as a hash to the `raise` method instead of an object. 

Code like `raise CustomError, object_implementing_to_hash`, which relies on `object_implementing_to_hash` to be an object, no longer works.

In this commit we ensure above code keeps working until keyword arguments are fixed in Ruby 3.2.
@rafaelfranca rafaelfranca merged commit 48b2993 into rails:main Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants