Project

General

Profile

Actions

Bug #17426

closed

method_missing can't override kernel#system method anymore

Added by freiden (charles fd) over 3 years ago. Updated over 3 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19]
[ruby-core:101629]

Description

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

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?

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0