[ruby-core:91600] [Ruby trunk Bug#15613] Enumerator::Chain#each doesn't relay block signature

From: ruby-core@...
Date: 2019-02-20 04:29:44 UTC
List: ruby-core #91600
Issue #15613 has been reported by marcandre (Marc-Andre Lafortune).

----------------------------------------
Bug #15613: Enumerator::Chain#each doesn't relay block signature
https://bugs.ruby-lang.org/issues/15613

* Author: marcandre (Marc-Andre Lafortune)
* Status: Open
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Target version: 
* ruby -v: 2.6.1
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Currently, the block given when iterating on the components of a `Enumerator::Chain` always have arity of -1 and `lambda?` is always `false`:

```ruby
class Foo
  include Enumerable
  def each(&block)
    return to_enum unless block
    p block.arity, block.lambda?
  end
end
foo = Foo.new

foo.each(&->{}) # => 0, true
foo.each.each(&->{}) # => 0, true
foo.chain.each(&->{}) # => -1, false. Would ideally be 0, true
```

It would be preferable if the block information wasn't lost.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next