diff options
author | Koichi Sasada <ko1@atdot.net> | 2024-04-17 19:46:48 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2024-04-17 20:26:49 +0900 |
commit | e9d7478dedbd2b57530bc17efe8a9db9b8b2f280 (patch) | |
tree | c41d4f58e25d3ca4532a60247c6019f6df767300 /test/ruby | |
parent | 6ade36c06b7cef948099b8f5f483763498705d12 (diff) |
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
```
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_method.rb | 14 |
1 files changed, 14 insertions, 0 deletions
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 |