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 B4C081F44D for ; Sun, 21 Apr 2024 07:02:21 +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=yn/n7Dyg; 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=YIdGrOBv; dkim-atps=neutral Received: from nue.mailmanlists.eu (localhost [127.0.0.1]) by nue.mailmanlists.eu (Postfix) with ESMTP id 103AE842F3; Sun, 21 Apr 2024 07:02:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1713682928; bh=5j+KDHHaYHf0B0NmUrX5xjYtUVqmdY9X81tgGgw5AWQ=; 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=yn/n7Dyg1KNm74zq/q+DC1i9U3UgUapSGxW9sg8/bteYuKJihhRvlkt1PNCacNBOO BOgEJF2jrMAJRubjhqwOKhNYJd0mLvQOQDmzLMnu4/Ueaj0d36iYj2bqLsMYaShl0Z 8RakDpK1+6nBqYFyYXOyQ8+DQr6H4m/HqZho74IQ= Received: from s.wfbtzhsv.outbound-mail.sendgrid.net (s.wfbtzhsv.outbound-mail.sendgrid.net [159.183.224.104]) by nue.mailmanlists.eu (Postfix) with ESMTPS id 4BD5383AE2 for ; Sun, 21 Apr 2024 07:02: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=YIdGrOBv; 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=svXxEPCuvgUXhJGgsvL2GJ/MhZlJTqmUK+8Q59WIPqg=; b=YIdGrOBvQMVgE1u3iOkGE8V4Sd18niXHecci6M5HTbNyVdJsqWh6g2ov8zC/QyXyMi/M Fkw49AC/Jx4oBbFeLp4bcZPLbWSeNd8WVLYSft7T95NjtgBoAeHuTG15Uwx9rZG+zMWYzn I0spw9fvPBl175eWoKpz4YUbRUXWoNO9cmpekVuNsYZh2MPqa0oN/PuqYwarRk8u9+TFuX lvGhbQXcRcRLpeWQ4YY7hi4/E9OiM5mzURpNNg2l44hox7SfiOXbS+oKNvnSapbBUZXoYv LC52+BT1kfSPzXPyDnRokGrq4etEpx1bCUq1WLHxDUNXaRGpClDJn88XDk8jIYEg== Received: by recvd-bb7996b79-ppnm7 with SMTP id recvd-bb7996b79-ppnm7-1-6624B9EB-11 2024-04-21 07:02:03.329402728 +0000 UTC m=+723746.974944143 Received: from herokuapp.com (unknown) by geopod-ismtpd-24 (SG) with ESMTP id BeZ225seQSKZ9k30v6oqTQ for ; Sun, 21 Apr 2024 07:02:03.272 +0000 (UTC) Date: Sun, 21 Apr 2024 07:02: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: ozydingo 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: 94224 X-SG-EID: =?us-ascii?Q?u001=2EWtjZePZ3IDDBwtRucCmuQUiYSyr+JPf+ZmCYBVn7D93R7gFrWGyOlEszX?= =?us-ascii?Q?asxAGqvNvImWJtoLSflkInthJWIzhiIJGtsXbiv?= =?us-ascii?Q?25bKX5XDbEYd6ekLwcHJhtt6rY=2FDbBxSyPOJz6g?= =?us-ascii?Q?UYtMhXygQf=2F5rUp84oPgj0K4opwHLlwHDyGyRTc?= =?us-ascii?Q?nRQtAZVdGqEUu43Uwx9XtCENvD2tRqSS0Ayr+nH?= =?us-ascii?Q?7eOkK81D8WJmywoXOhizUZ61+C8tjSE5B5OPScQ?= =?us-ascii?Q?Vs+OYEUmlM8Y2VSVne6Dq=2F+uQg=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: T7KPRBQHJQT5PIYR7MKA7ETK2VZKBMDW X-Message-ID-Hash: T7KPRBQHJQT5PIYR7MKA7ETK2VZKBMDW 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:117628] [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: "ozydingo (Andrew Schwartz) via ruby-core" Cc: "ozydingo (Andrew Schwartz)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #20440 has been updated by ozydingo (Andrew Schwartz). Thanks both. I understand that Ruby 3 requires explicit handling of keyword arguments. What still seems off to me is that `super` is _modifying_ the arguments. The child method is being passed a keyword argument, and `super` is forwarding keywords arguments *and* a Hash positional argument. Should it not be the case that either the method defined with only `*` does not accept keyword arguments or that `super` preserves the form of the arguments that were passed? ---------------------------------------- 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-108036 * Author: ozydingo (Andrew Schwartz) * Status: Closed * 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/