[ruby-core:112854] [Ruby master Bug#19526] Rails Active Support behavior change since e87d0882910001ef3b0c2ccd43bf00cee8c34a0c
From:
"yahonda (Yasuo Honda) via ruby-core" <ruby-core@...>
Date:
2023-03-12 04:26:39 UTC
List:
ruby-core #112854
Issue #19526 has been reported by yahonda (Yasuo Honda).
----------------------------------------
Bug #19526: Rails Active Support behavior change since e87d0882910001ef3b0c2ccd43bf00cee8c34a0c
https://bugs.ruby-lang.org/issues/19526
* Author: yahonda (Yasuo Honda)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.3.0dev (2023-03-06T06:03:06Z master e87d088291) [x86_64-linux]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
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
```ruby
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.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/