mirror of
https://github.com/ruby/ruby.git
synced 2025-08-25 22:14:37 +02:00
Make Enumerator::Chain#each treat lambdas as lambda
Previously, lambdas were converted to procs because of how rb_block_call works. Switch to rb_funcall_with_block, which handles procs as procs and lambdas as lambdas. Fixes [Bug #15613]
This commit is contained in:
parent
47c97e1e84
commit
a029b54ec7
Notes:
git
2019-12-04 06:18:53 +09:00
2 changed files with 17 additions and 8 deletions
|
@ -864,4 +864,20 @@ class TestEnumerator < Test::Unit::TestCase
|
|||
], enum.to_a
|
||||
}
|
||||
end
|
||||
|
||||
def test_chain_each_lambda
|
||||
c = Class.new do
|
||||
include Enumerable
|
||||
attr_reader :is_lambda
|
||||
def each(&block)
|
||||
return to_enum unless block
|
||||
@is_lambda = block.lambda?
|
||||
end
|
||||
end
|
||||
e = c.new
|
||||
e.chain.each{}
|
||||
assert_equal(false, e.is_lambda)
|
||||
e.chain.each(&->{})
|
||||
assert_equal(true, e.is_lambda)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue