ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: Mauricio Fernandez <mfp@acm.org>
To: ruby-core@ruby-lang.org
Subject: [BUG] Proc#arity regression or bug in RDoc
Date: Thu, 26 Apr 2007 18:55:46 +0900	[thread overview]
Message-ID: <20070426095541.GU17734@tux-chan> (raw)


$ ruby19 -v -e "p proc{}.arity"
ruby 1.9.0 (2007-02-07 patchlevel 0) [i686-linux]
0
$ ./ruby19 -v -e "p proc{}.arity"
ruby 1.9.0 (2007-04-26 patchlevel 0) [i686-linux]
-1

However, the RDoc documentation attached to proc_arity still says that it
should return 0, so there's a bug, either in the code (wrong iseq->argc ?) or
in the docs (if the latter, the patch below should do).

See also 
 [ruby-core:2829]
 [ruby-core:11026]
 [ruby-talk:249148]

\f
--- proc.c.orig	2007-04-26 11:48:35.000000000 +0200
+++ proc.c	2007-04-26 11:49:34.000000000 +0200
@@ -410,15 +410,14 @@
  *  call-seq:
  *     prc.arity -> fixnum
  *  
- *  Returns the number of arguments that would not be ignored. If the block
- *  is declared to take no arguments, returns 0. If the block is known
- *  to take exactly n arguments, returns n. If the block has optional
- *  arguments, return -n-1, where n is the number of mandatory
- *  arguments. A <code>proc</code> with no argument declarations
- *  is the same a block declaring <code>||</code> as its arguments.
+ *  If the block is declared to take no arguments, returns -1. If the block is
+ *  known to take exactly n arguments, returns n. If the block has optional
+ *  arguments, return -n-1, where n is the number of mandatory arguments. A
+ *  <code>proc</code> with no argument declarations is the same a block
+ *  declaring <code>||</code> as its arguments.
  *     
- *     Proc.new {}.arity          #=>  0
- *     Proc.new {||}.arity        #=>  0
+ *     Proc.new {}.arity          #=>  -1
+ *     Proc.new {||}.arity        #=>  -1
  *     Proc.new {|a|}.arity       #=>  1
  *     Proc.new {|a,b|}.arity     #=>  2
  *     Proc.new {|a,b,c|}.arity   #=>  3
\f


-- 
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

             reply	other threads:[~2007-04-26  9:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-26  9:55 Mauricio Fernandez [this message]
2007-04-26 10:40 ` [BUG] Proc#arity regression or bug in RDoc Mauricio Fernandez
2007-04-27  5:12   ` [patch] " Adam Bozanich
2007-04-29  4:37     ` Adam Bozanich
2007-05-01  4:19     ` SASADA Koichi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070426095541.GU17734@tux-chan \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).