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.1 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, 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 0E386211BB for ; Fri, 28 Dec 2018 05:28:08 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 3524F1219E3; Fri, 28 Dec 2018 14:28:05 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id 093451219D6 for ; Fri, 28 Dec 2018 14:28:02 +0900 (JST) Received: by filter0163p3mdw1.sendgrid.net with SMTP id filter0163p3mdw1-26626-5C25B460-1C 2018-12-28 05:28:00.521681963 +0000 UTC m=+631340.316680233 Received: from herokuapp.com (ec2-54-162-170-205.compute-1.amazonaws.com [54.162.170.205]) by ismtpd0041p1mdw1.sendgrid.net (SG) with ESMTP id vebixsteRMmou2YfHyNw9g for ; Fri, 28 Dec 2018 05:28:00.406 +0000 (UTC) Date: Fri, 28 Dec 2018 05:28:01 +0000 (UTC) From: robb+ruby@weblaws.org To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 66187 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15477 X-Redmine-Issue-Author: robb X-Redmine-Sender: robb 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: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS5RLc0dIukaYCKusDJ85gcDfDCK6naMq5egll uAHSHbhsZ9KOjd3cDvZNyHXy935nrvCiEwLae7fy7wXkl2ziVq6vj3daW+pkNPXjGrqID6YIpQZGb9 MtsK2nKT50K4tbWS+kLlFt7+qb1Zbx0Z9+U3bwnG03LdAfBVhyBkv037oQ== X-ML-Name: ruby-core X-Mail-Count: 90767 Subject: [ruby-core:90767] [Ruby trunk Bug#15477] Proc#arity returns -1 for composed lambda Procs of known arguments 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 #15477 has been reported by robb (Robb Shecter). ---------------------------------------- Bug #15477: Proc#arity returns -1 for composed lambda Procs of known arguments https://bugs.ruby-lang.org/issues/15477 * Author: robb (Robb Shecter) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux] * Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- ``` f = -> x { x + 2 } g = -> x { x * 2 } h = f << g f.arity # => 1 g.arity # => 1 h.arity # => -1 THIS SHOULD BE 1 because h "knows" that it takes exactly 1 argument: h.call # => ArgumentError (given 0, expected 1) ``` Lambda Procs which are composed using `<<` seem to partially lose knowledge of their arity. I don't know if this affects other procs, or the `>>` operator as well. The Proc#arity docs state that -1 is returned only when a variable or unknown number of arguments are expected by the Proc. But here, that's not the case. -- https://bugs.ruby-lang.org/