Project

General

Profile

Actions

Feature #17660

open

Expose information about which basic methods have been redefined

Added by tenderlovemaking (Aaron Patterson) over 3 years ago. Updated over 3 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:102631]

Description

I would like to tell if code is redefining methods that can impact
MRI's optimizations. This commit exposes which basic methods have been
redefined. For example:

class Integer
  def +(x); x ** self; end
end

p RubyVM.redefined_methods # => {Integer=>[:+]}

This will allow us to prevent basic method redefinitions from happening
by checking for them in CI environments. For example:

Minitest.after_run {
  fail "Basic methods have been redefine" if RubyVM.redefined_methods.any?
}

Files

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0