Project

General

Profile

Actions

Bug #19526

closed

Rails Active Support behavior change since e87d0882910001ef3b0c2ccd43bf00cee8c34a0c

Added by yahonda (Yasuo Honda) over 1 year ago. Updated over 1 year ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.3.0dev (2023-03-06T06:03:06Z master e87d088291) [x86_64-linux]
[ruby-core:112854]

Description

This issue has been opened while investigating Rails issue https://github.com/rails/rails/issues/47627#issuecomment-1464724436

Steps to reproduce

  • Run this script saves as diag47627.rb
options = { hello: "world" }

def test(opts) = opts

puts test(*[], **options).equal?(options)

Expected behavior

It returns false as Ruby 3.2.1 and Ruby 3.3.0dev 0463c5806a does

$ ruby -v
ruby 3.3.0dev (2023-03-06T05:52:46Z master 0463c5806a) [x86_64-linux]
$ ruby diag47627.rb
false
$
$ ruby -v
ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x86_64-linux]
$ ruby diag47627.rb
false

Actual behavior

It returns true

$ ruby -v
ruby 3.3.0dev (2023-03-06T06:03:06Z master e87d088291) [x86_64-linux]
$ ruby diag47627.rb
true

Workaround

Duplicate the value inside the method that restores the original behavior.

  • another_diag47627.rb
options = { hello: "world" }

def test(opts) = opts.dup

puts test(*[], **options).equal?(options)
$ ruby -v
ruby 3.3.0dev (2023-03-06T05:52:46Z master 0463c5806a) [x86_64-linux]
$ ruby another_diag47627.rb
false
$

At the Rails side, reverting https://github.com/rails/rails/commit/9e4ff29f748b05c3a949f0d75167950039b6cda8
can also workaround it.

Actions

Also available in: Atom PDF

Like0
Like0