From 2188d6d160d3ba82432c87277310a4d417e136d5 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Wed, 10 Jun 2020 17:50:35 -0700 Subject: Warn when passing a non-literal block to Kernel#lambda Implements [Feature #15973] --- test/ruby/test_iterator.rb | 3 +-- test/ruby/test_lambda.rb | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'test/ruby') diff --git a/test/ruby/test_iterator.rb b/test/ruby/test_iterator.rb index 54c095338f..820d5591c1 100644 --- a/test/ruby/test_iterator.rb +++ b/test/ruby/test_iterator.rb @@ -339,8 +339,7 @@ class TestIterator < Test::Unit::TestCase marity_test(:marity_test) marity_test(:p) - lambda(&method(:assert)).call(true) - lambda(&get_block{|a,n| assert(a,n)}).call(true, "marity") + get_block{|a,n| assert(a,n)}.call(true, "marity") end def foo diff --git a/test/ruby/test_lambda.rb b/test/ruby/test_lambda.rb index 03b501a6c9..75362e2796 100644 --- a/test/ruby/test_lambda.rb +++ b/test/ruby/test_lambda.rb @@ -74,6 +74,12 @@ class TestLambdaParameters < Test::Unit::TestCase assert_raise(ArgumentError, bug9605) {proc(&plus).call [1,2]} end + def test_warning_for_non_literal_blocks + assert_warn(/lambda without a literal block/, '[ruby-core:93482] [Feature #15973]') do + lambda(&:symbol) + end + end + def pass_along(&block) lambda(&block) end -- cgit v1.2.3