From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id AE1281F461 for ; Mon, 19 Aug 2019 06:13:14 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id D5A83120A2B; Mon, 19 Aug 2019 15:13:06 +0900 (JST) Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 81D39120A1F for ; Mon, 19 Aug 2019 15:13:03 +0900 (JST) Received: by filter0077p3las1.sendgrid.net with SMTP id filter0077p3las1-13783-5D5A3DF2-18 2019-08-19 06:13:06.548771098 +0000 UTC m=+130281.179433868 Received: from herokuapp.com (unknown [54.80.45.23]) by ismtpd0014p1iad2.sendgrid.net (SG) with ESMTP id XiGFvXCwS-mbhZPxJV8uPg for ; Mon, 19 Aug 2019 06:13:06.174 +0000 (UTC) Date: Mon, 19 Aug 2019 06:13:06 +0000 (UTC) From: mame@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 69971 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 16111 X-Redmine-Issue-Author: mtelford X-Redmine-Sender: mame 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-SG-EID: =?us-ascii?Q?EJh2gqwnyqXtd++xo=2FinyA1V0bXouTB4FkWnzNiKb49V5C9Fng2gNW28duWwG=2F?= =?us-ascii?Q?mssYqeOJOW3788cN+AH0wY6e4lIcCDBRBDKcPWk?= =?us-ascii?Q?xgP2MbQXO2BrsiYsko4nq3iZ+lb7h481fI1X6lj?= =?us-ascii?Q?RtL=2FXztvKPMtQ1t=2FD=2Fu2BsOzDqbEySqQ9jzMpLj?= =?us-ascii?Q?lEBONxxl7goyPlR88oze4QI7D7gZ=2FKKoixA=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 94423 Subject: [ruby-core:94423] [Ruby master Bug#16111] Combining default positional and keyword arguments is resulting in a `to_hash` method call X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #16111 has been updated by mame (Yusuke Endoh). > I would like to know why the method to_hash is being called A method call that accepts keywords checks if the last argument is a Hash or not. The check includes attempting to convert it by using `to_hash`. This is the behavior you are seeing. I agree that it is very strange. It is elegantly solved if we can separate positional and keyword arguments completely (#14183), but the separation seems to be difficult because the incompatibility is painful. ---------------------------------------- Bug #16111: Combining default positional and keyword arguments is resulting in a `to_hash` method call https://bugs.ruby-lang.org/issues/16111#change-80848 * Author: mtelford (Michael Telford) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: 2.6.3 * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- Combining default positional and keyword arguments is resulting in a `to_hash` method call when I don't believe it should be. It's affecting some code I am writing. The full details of the behaviour I'm describing can be seen in the attached script. I would like to know why the method `to_hash` is being called (only in certain circumstances) and if this is a bug to be fixed or desired behaviour (and why?). Thank in advance! ---Files-------------------------------- ruby-bug.rb (1.44 KB) -- https://bugs.ruby-lang.org/