From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (8.12.3/8.12.3/Debian-6.6) with ESMTP id l3TAvErU001997 for ; Sun, 29 Apr 2007 19:57:15 +0900 Received: from funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 78C676B19 for ; Sun, 29 Apr 2007 19:57:15 +0900 (JST) Received: from localhost (localhost.nagaokaut.ac.jp [127.0.0.1]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id CFF68F04846 for ; Sun, 29 Apr 2007 19:57:18 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 99CD8F0486F for ; Sun, 29 Apr 2007 19:57:15 +0900 (JST) Received: from carbon.ruby-lang.org (carbon.ruby-lang.org [221.186.184.68]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 58443630053 for ; Sun, 29 Apr 2007 19:57:16 +0900 (JST) Received: from beryllium.ruby-lang.org (beryllium.ruby-lang.org [127.0.0.1]) by carbon.ruby-lang.org (Postfix) with ESMTP id A22023C223A58; Sun, 29 Apr 2007 19:57:01 +0900 (JST) Received: from ctsmtpout2.frontal.correo (smtp.telefonica.net [213.4.149.66]) by carbon.ruby-lang.org (Postfix) with ESMTP id 9D2CD3C21D3B4 for ; Sun, 29 Apr 2007 19:56:57 +0900 (JST) Received: from tux-chan (83.60.155.42) by ctsmtpout2.frontal.correo (7.2.056.6) (authenticated as ferferse$telefonica.net) id 462E533500116296 for ruby-core@ruby-lang.org; Sun, 29 Apr 2007 12:56:55 +0200 Received: from batsman by tux-chan with local (Exim 3.36 #1 (Debian)) id 1Hi75K-0007LC-00 for ; Sun, 29 Apr 2007 12:56:54 +0200 Delivered-To: ruby-core@ruby-lang.org Date: Sun, 29 Apr 2007 19:56:58 +0900 Posted: Sun, 29 Apr 2007 12:56:54 +0200 From: Mauricio Fernandez Reply-To: ruby-core@ruby-lang.org Subject: [BUG] (1.9) Wrong arity of Procs obtained with somemethod.to_proc. Sender: =?iso-8859-1?Q?Mauricio_Julio_Fern=E1ndez_Pradier?= To: ruby-core@ruby-lang.org Message-Id: <20070429105654.GA13431@tux-chan> X-ML-Name: ruby-core X-Mail-Count: 11060 X-MLServer: fml [fml 4.0.3 release (20011202/4.0.3)]; post only (only members can post) X-ML-Info: If you have a question, send e-mail with the body "help" (without quotes) to the address ruby-core-ctl@ruby-lang.org; help= User-Agent: Mutt/1.5.11 X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on carbon.ruby-lang.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=7.0 tests=AWL,BAYES_00, CONTENT_TYPE_PRESENT,EXIM_ERRWARN,FORGED_RCVD_HELO,RIPE_NCC autolearn=disabled version=3.1.7 X-Original-To: ruby-core@ruby-lang.org Content-Disposition: inline Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Precedence: bulk List-Id: ruby-core.ruby-lang.org List-Software: fml [fml 4.0.3 release (20011202/4.0.3)] List-Post: List-Owner: List-Help: List-Unsubscribe: X-Virus-Scanned: by amavisd 0.1 $ ./ruby19 -ve "def foo(a, x, y, *b); end; p method(:foo).to_proc.arity" ruby 1.9.0 (2007-04-26 patchlevel 0) [i686-linux] -1 when it should resemble $ ruby185-p12 -ve "def foo(a, x, y, *b); end; p method(:foo).to_proc.arity" ruby 1.8.5 (2006-12-25 patchlevel 12) [i686-linux] -4 The bug is distinct from the one in [ruby-core:11029] and predates it. The comment in the function is very telling: static VALUE method_proc(VALUE method) { VALUE proc; /* * class Method * def to_proc * proc{|*args| * self.call(*args) * } * end * end */ proc = rb_iterate((VALUE (*)(VALUE))mproc, 0, bmcall, method); return proc; } In proc_arity, the second branch is being followed: if (iseq && BUILTIN_TYPE(iseq) != T_NODE) { if (iseq->arg_rest == 0 && iseq->arg_opts == 0) { return INT2FIX(iseq->argc); } else { return INT2FIX(-iseq->argc - 1); } } else { return INT2FIX(-1); } -- Mauricio Fernandez - http://eigenclass.org - singular Ruby ** Latest postings ** On GC and finalizers in Ruby, corrected weak hash table implementations http://eigenclass.org/hiki/deferred-finalizers-in-Ruby simplefold: better vim folding (Ruby, Objective Caml, Perl, PHP, Java) http://eigenclass.org/hiki/simplefold