From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from nue.mailmanlists.eu (nue.mailmanlists.eu [IPv6:2a01:4f8:1c0c:6b10::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 1B5601F44D for ; Sat, 20 Apr 2024 09:55:51 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; secure) header.d=ml.ruby-lang.org header.i=@ml.ruby-lang.org header.a=rsa-sha256 header.s=mail header.b=dn4tReCe; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=CHg2Uj6a; dkim-atps=neutral Received: from nue.mailmanlists.eu (localhost [127.0.0.1]) by nue.mailmanlists.eu (Postfix) with ESMTP id EBAD4844D7; Sat, 20 Apr 2024 09:55:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1713606943; bh=KlJum4lidy+I+VYY9bYSLd4WtGizyS6/NT3XeTxQ16U=; h=Date:References:To:Reply-To:Subject:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From:Cc:From; b=dn4tReCep/EEwIOFITIitl9ZIVwOW026MividZ3HB9v7wl9aM014GZnbkaj44GLgd 6iKClbkAAx3v1lmEUcRYYRnNBOXaelb4rtNPJGKnIhm+WNZu4Tm6nLcrVFCcpx/QbN XmkMg6pvaDxGgCM/Ueq3MGchn0hbJX1p1Z2QdayM= Received: from s.wfbtzhsw.outbound-mail.sendgrid.net (s.wfbtzhsw.outbound-mail.sendgrid.net [159.183.224.105]) by nue.mailmanlists.eu (Postfix) with ESMTPS id 74118844A7 for ; Sat, 20 Apr 2024 09:55:04 +0000 (UTC) Authentication-Results: nue.mailmanlists.eu; dkim=pass (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=CHg2Uj6a; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ruby-lang.org; h=from:references:subject:mime-version:content-type: content-transfer-encoding:list-id:to:cc:content-type:from:subject:to; s=s1; bh=pdIJ55oOLh34Pj2oRq9JFVU6y1Q+JubPUpC08sv19MI=; b=CHg2Uj6al7jCUBE9lEeFNprOHRnBE34S7PawiplFAV4ZO6FgwXEgwTWZ+14mbyz2xBJO NSB9aPPijBREQxTJvQ66nArlgUz2FANbphgeCJBZURcuwvHlrSb90GadiOTIXb/hcUDH9M nwMuvBi6PSC14JlPKQ+LHAkaT4kEmCW13CGxit9VCGyiWyLETdsGWfeMjVXHidTbqvZgY2 dBWqCmiUDiLOj5CzKr+nxmAG6I/WW768wcCF2Ts+DKI2Jcw6ZyPnp2GUUurVDY8UpgV0p9 mXs6SyYoZX2c/UE/0xPF59+lb6j6bHRVZzCgVtRSpU3eoN7Vik5zLVowrsPBgtnA== Received: by filterdrecv-854b845bd5-h2xfw with SMTP id filterdrecv-854b845bd5-h2xfw-1-662390F7-13 2024-04-20 09:55:03.580959275 +0000 UTC m=+648335.058762619 Received: from herokuapp.com (unknown) by geopod-ismtpd-31 (SG) with ESMTP id 1LeDZnMYSeGAyFb7oOQdwQ for ; Sat, 20 Apr 2024 09:55:03.542 +0000 (UTC) Date: Sat, 20 Apr 2024 09:55:03 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 20440 X-Redmine-Issue-Author: ozydingo X-Redmine-Issue-Priority: Normal X-Redmine-Sender: nobu X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-Redmine-MailingListIntegration-Message-Ids: 94222 X-SG-EID: =?us-ascii?Q?u001=2E5PtzXJ23KrYzgM1nrOIr+EQ222PyrDaWSg0Er8CZ8tP86xyXmBM81zBKD?= =?us-ascii?Q?HreavdFYMbHjxXOR6UPMkt=2Fu9CyBIp6y52n8D2y?= =?us-ascii?Q?qA9zqurrgUcoAoiXB3hiNRRqu1OKx2qm75aw3kg?= =?us-ascii?Q?bbvTjdRM1wSIyKqjeSJfftuMooruXxuc7IR0HXh?= =?us-ascii?Q?qwp6B61pPKcj7qKKD9xKn85wXjhxfFqikJXnXHu?= =?us-ascii?Q?sTkqtzSp5rUb7OnU3Bu42+g7mjqgfbD1ATGn22y?= =?us-ascii?Q?aztEOEFCYvV4g=2F11A2TFoK+Iyw=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: LTWHFJMUG7IJDMTP2SAAFRISKY56J3ZO X-Message-ID-Hash: LTWHFJMUG7IJDMTP2SAAFRISKY56J3ZO X-MailFrom: bounces+313651-b711-ruby-core=ml.ruby-lang.org@em5188.ruby-lang.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list Reply-To: Ruby developers Subject: [ruby-core:117626] [Ruby master Bug#20440] `super` from child class passing keyword arg as Hash if in a method with passthrough args called from base class List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "nobu (Nobuyoshi Nakada) via ruby-core" Cc: "nobu (Nobuyoshi Nakada)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #20440 has been updated by nobu (Nobuyoshi Nakada). You need to make `foo` `ruby2_keywords` to let it work as same as 2.7 or earlier. ```rb class Child < Base ruby2_keywords def foo(*) puts "Child: calling foo" super end end Child.new.foo! ``` ``` Base: calling foo! with x: 1 Child: calling foo Base: calling foo with args: [], x: 1 ``` Note that `require 'ruby2_keyword'` is necessary before ruby 2.7. ---------------------------------------- Bug #20440: `super` from child class passing keyword arg as Hash if in a method with passthrough args called from base class https://bugs.ruby-lang.org/issues/20440#change-108033 * Author: ozydingo (Andrew Schwartz) * Status: Open * ruby -v: 3.3.0 * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- Apologies for the verbose title, but that's the specific set of conditions that AFAICT are required to reproduce the bug! Here's the simplest setup I can reproduce: ```rb class Base def foo(*args, x: 1) puts "Base: calling foo with args: #{args}, x: #{x}" end def foo!(x: 1) puts "Base: calling foo! with x: #{x}" foo(x: x) end end class Child < Base def foo(*) puts "Child: calling foo" super end end ``` When I call `Child.new.foo!`, I expect it to call the base class method `foo!`, which will use the default keyword arg `x: 1`; then the child method `foo` with `x: 1`, and finally the base method `foo` with `x: 1`. However, this is not what I observe: ```rb Child.new.foo! Base: calling foo! with x: 1 Child: calling foo Base: calling foo with args: [{:x=>1}], x: 1 ``` So when the child `foo` method called `super`, it passed not only `x: 1` as a keyword arg, but *also* `{x: 1}` as a Hash positional arg to the super method. This is breaking my upgrade to Ruby 3.0 as I have a similar setup but without the `*args` param, this I am getting the error "wrong number of arguments (given 1, expected 0)". -- 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/