[ruby-core:96186] [Ruby master Bug#16414] Incompatible behavior of Proc/lambda with single argument when using `Enumerator::Lazy#with_index`

[email protected]
Newsgroups gmane.comp.lang.ruby.core
Message-ID <redmine.issue-16414.20191210130922.ec30da81a23eebdf@ruby-lang.org>
Issue #16414 has been reported by tomog105 (Tomohiro Ogoke).

----------------------------------------
Bug #16414: Incompatible behavior of Proc/lambda with single argument when using `Enumerator::Lazy#with_index`
https://bugs.ruby-lang.org/issues/16414

* Author: tomog105 (Tomohiro Ogoke)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.7.0dev (2019-12-10T10:12:21Z master af11efd377) [x86_64-darwin18]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Following code is raised error `wrong number of arguments (given 1, expected 2) (ArgumentError)` in master.

```
$ ruby -e 'lambda = -> (s, i) { "#{i}:#{s}" }; p %w(a b c).each.lazy.with_index.map(&lambda).first(2)'
# expect results => ["0:a", "1:b"]
```

This code is valid until Ruby 2.6.5 and 2.7.0-preview1, but raised error since Ruby 2.7.0-preview2.
(Maybe, this behavior has been since the implementation of `Enumerator::Lazy#with_index`.)

Is this behaviour intentional change?



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

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.