ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: matz@ruby-lang.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:90978] [Ruby trunk Feature#15477] Proc#arity returns -1 for composed lambda Procs of known arguments
Date: Thu, 10 Jan 2019 08:04:30 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-76191.20190110080428.b16b45fdf63ba26c@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15477.20181228052759@ruby-lang.org

Issue #15477 has been updated by matz (Yukihiro Matsumoto).


Yes, please.

Matz.


----------------------------------------
Feature #15477: Proc#arity returns -1 for composed lambda Procs of known arguments
https://bugs.ruby-lang.org/issues/15477#change-76191

* Author: robb (Robb Shecter)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
```
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/

  parent reply	other threads:[~2019-01-10  8:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-15477.20181228052759@ruby-lang.org>
2018-12-28  5:28 ` [ruby-core:90767] [Ruby trunk Bug#15477] Proc#arity returns -1 for composed lambda Procs of known arguments robb+ruby
2019-01-01 11:09 ` [ruby-core:90842] [Ruby trunk Feature#15477] " mame
2019-01-10  8:04 ` matz [this message]
2019-03-15 12:39 ` [ruby-core:91849] " mathias

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=redmine.journal-76191.20190110080428.b16b45fdf63ba26c@ruby-lang.org \
    --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).