From: merch-redmine@... Date: 2020-09-19T22:07:12+00:00 Subject: [ruby-core:100050] [Ruby master Bug#17179] Unexpected warning when value assignment to setter Issue #17179 has been updated by jeremyevans0 (Jeremy Evans). Status changed from Open to Rejected This is expected behavior in Ruby 2.7, due to keyword argument separation. The warning is valid because the code will cause an ArgumentError in Ruby 3. You should not use keywords parameters if you want to assign a hash. Instead, you should have the method accept a single hash argument. Note that calling the method directly with keywords will not cause a warning. `some_instance.send(:some_setter=, :a=>1, :b=>2)` doesn't warn, but `some_instance.send(:some_setter=, {:a=>1, :b=>2})` does. ---------------------------------------- Bug #17179: Unexpected warning when value assignment to setter https://bugs.ruby-lang.org/issues/17179#change-87600 * Author: bestwebua (Vladislav Trotsenko) * Status: Rejected * Priority: Normal * ruby -v: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- ```ruby some_instance = Class.new { def some_setter=(a:, b:); end }.new setter_params = { a: 1, b: 2 } some_instance.some_setter = setter_params # => {:a=>1, :b=>2} # warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call # warning: The called method `some_setter=' is defined here some_instance.public_send(:some_setter=, **setter_params) # => nil # No warninigs, everything is ok ``` If this behavior is okay, probably need to add ability to use double splat operator with syntax sugar like in example below: ```ruby some_instance.some_setter = **setter_params ``` -- https://bugs.ruby-lang.org/ Unsubscribe: