Project

General

Profile

Actions

Bug #17481

closed

Keyword arguments change value after calling super without arguments in Ruby 3.0

Added by janko (Janko Marohnić) over 3 years ago. Updated over 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
[ruby-core:101741]

Description

There seems to be a bug in Ruby 3.0 regarding keyword arguments and calling super without arguments, where the splatted variable changes its value after super is called. The following self-contained example reproduces the issue:

class BaseTest
  def call(a:, b:, **)
  end
end

class Test < BaseTest
  def call(a:, b:, **options)
    p options
    super
    p options
  end
end

Test.new.call(a: 1, b: 2, c: {})
{:c=>{}}
{:c=>{}, :a=>1, :b=>2}

We can see that the options variable changed value to all keyword arguments after super was called. This doesn't happen when explicitly passing arguments to super, i.e. super(a: a, b: b, **options).

Actions #2

Updated by nobu (Nobuyoshi Nakada) over 3 years ago

  • Status changed from Open to Closed

Applied in changeset git|c8010fcec016ee89aa0c45fe31094b2db0023e5c.


Dup kwrest hash when merging other keyword arguments [Bug #17481]

Actions

Also available in: Atom PDF

Like0
Like0Like0