mirror of
https://github.com/ruby/ruby.git
synced 2025-09-23 12:33:56 +02:00
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:
parent
db84123600
commit
2993b24a1e
Notes:
git
2019-10-17 04:51:04 +09:00
3 changed files with 67 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue