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-Status: No, score=-2.6 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=no 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 867FE1F66F for ; Mon, 16 Nov 2020 22:37:09 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 7B189120968; Tue, 17 Nov 2020 07:36:26 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 9EA91120959 for ; Tue, 17 Nov 2020 07:36:24 +0900 (JST) Received: by filterdrecv-p3mdw1-5f8d7bb6d9-4l96m with SMTP id filterdrecv-p3mdw1-5f8d7bb6d9-4l96m-20-5FB2FF10-39 2020-11-16 22:37:04.398559281 +0000 UTC m=+7568.490117834 Received: from herokuapp.com (unknown) by ismtpd0012p1iad2.sendgrid.net (SG) with ESMTP id 5ucCgL1ySZ6BWz4wS3Gyeg for ; Mon, 16 Nov 2020 22:37:04.286 +0000 (UTC) Date: Mon, 16 Nov 2020 22:37:04 +0000 (UTC) From: eregontp@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 76753 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 17197 X-Redmine-Issue-Author: marcandre X-Redmine-Issue-Assignee: nobu X-Redmine-Sender: Eregon 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?KippOI8ZHtTweq7XfQzW93937kJ4QNWwSBuHnaMEcr25GyDpYTlW3vGtNxsp3U?= =?us-ascii?Q?aYnOUus8+EKBAekjzGCBJuc5D5J3oGu8KvtWnDK?= =?us-ascii?Q?gFVabXdD504HM2oORXay33lK7dVyC8TAk+W9myU?= =?us-ascii?Q?DWgKEWQHR0xeiY+PXmGcG1LoXtAj4d1vduuNU2P?= =?us-ascii?Q?PwVgNyOp14FwfA3YVcp49sqrEaOp+S3pmGIgmsn?= =?us-ascii?Q?NbYv15bCJuMu19b0g=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 100880 Subject: [ruby-core:100880] [Ruby master Bug#17197] Some Hash methods still have arity 2 instead of 1 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 #17197 has been updated by Eregon (Benoit Daloze). @Dan0042 How would we warn that case? Check if the block uses arity 1 and warn that it should instead use `|k,v|` or `|k,|`? I think we should fix `Hash#map` at least, that's also a clear optimization bug like `Hash#each`, and it forces other Ruby implementations to replicate the bug. (e.g., https://github.com/oracle/truffleruby/issues/1944) ---------------------------------------- Bug #17197: Some Hash methods still have arity 2 instead of 1 https://bugs.ruby-lang.org/issues/17197#change-88528 * Author: marcandre (Marc-Andre Lafortune) * Status: Open * Priority: Normal * Assignee: nobu (Nobuyoshi Nakada) * ruby -v: ruby 3.0.0dev (2020-09-26T17:38:39Z master 950614b088) * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- `Hash#each` was changed recently to have arity of 1. All other methods of `Hash` should behave the same. Much has been fixed since #14015, but some remains: ```ruby # Some methods consistently have arity 2: {a: 1}.select( &->(_kvp) {} ) # => ArgumentError (wrong number of arguments (given 2, expected 1)) ``` All in all: `%i[select keep_if delete_if reject to_h]` have their arity still set at 2. -- https://bugs.ruby-lang.org/