From e9d7478dedbd2b57530bc17efe8a9db9b8b2f280 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Wed, 17 Apr 2024 19:46:48 +0900 Subject: relax unused block warning for duck typing if a method `foo` uses a block, other (unrelated) method `foo` can receives a block. So try to relax the unused block warning condition. ```ruby class C0 def f = yield end class C1 < C0 def f = nil end [C0, C1].f{ block } # do not warn ``` --- test/ruby/test_method.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index a41704cf06..5301b51650 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -1692,5 +1692,19 @@ class TestMethod < Test::Unit::TestCase assert_match(/-:23: warning.+f5/, err.join) assert_match(/-:24: warning.+f6/, err.join) end + + assert_in_out_err '-w', <<-'RUBY' do |_out, err, _status| + class C0 + def f = yield + end + + class C1 < C0 + def f = nil + end + + C1.new.f{} # do not warn on duck typing + RUBY + assert_equal 0, err.size, err.join("\n") + end end end -- cgit v1.2.3