From a029b54ec716812ade37fef1f857c49f821a8cc8 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Wed, 28 Aug 2019 16:41:39 -0700 Subject: 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] --- test/ruby/test_enumerator.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test') diff --git a/test/ruby/test_enumerator.rb b/test/ruby/test_enumerator.rb index 65adb5a438..75cf1aeec6 100644 --- a/test/ruby/test_enumerator.rb +++ b/test/ruby/test_enumerator.rb @@ -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 -- cgit v1.2.3