Issue #17426 has been updated by nobu (Nobuyoshi Nakada).
Or, use other than the literal `self`.
```ruby
self.system("true") #=> runs `true` command
(self).system("true") #=> private method `system' called for main:Object (NoMethodError)
```
----------------------------------------
Bug #17426: method_missing can't override kernel#system method anymore
https://bugs.ruby-lang.org/issues/17426#change-89431
* Author: freiden (charles fd)
* Status: Rejected
* Priority: Normal
* ruby -v: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
Hello,
It seems like I found a behavior change on the way method missing is working on Ruby 2.7.2 in comparison with 2.6.6.
`method_missing` can't intercept call to a method called `system`.
The following code help reproducing the behavior
```ruby
class Klass
def method_missing(meth, *args, &blk)
if %i[system foo].include?(meth)
puts 'behavior not reproductible'
else
super
end
end
# Work on 2.6.6
def call_system_from_self
self.system
end
# Doesn't work on both
def call_system_from_implicit_self
system
end
# Work on both
def call_foo_from_self
self.foo
end
# Work on both
def call_foo_from_implicit_self
foo
end
# Doesn't work on both
def call_system_with_send_from_self
self.send(:system)
end
# Work on both
def call_foo_with_send_from_self
self.send(:foo)
end
# Work on both
def call_system_with_public_send
self.public_send(:system)
end
# Work on both
def call_foo_with_public_send
self.public_send(:foo)
end
end
```
Is it an expected behavior change in 2.7.2?
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>