Warn for calling public/protected/private/module_function without arguments inside method

Calling these methods without an argument does not have the
desired effect inside a method.

Fixes [Bug #13249]
This commit is contained in:
Jeremy Evans 2019-08-24 17:11:06 -07:00
parent db84123600
commit 2993b24a1e
Notes: git 2019-10-17 04:51:04 +09:00
3 changed files with 67 additions and 1 deletions

View file

@ -1394,6 +1394,17 @@ class TestModule < Test::Unit::TestCase
assert_match(/: warning: previous definition of foo/, stderr)
end
def test_module_function_inside_method
assert_warn(/calling module_function without arguments inside a method may not have the intended effect/, '[ruby-core:79751]') do
Module.new do
def self.foo
module_function
end
foo
end
end
end
def test_protected_singleton_method
klass = Class.new
x = klass.new