Project

General

Profile

Actions

Feature #20317

open

Removing the `allocate` method should cause `new` to fail

Added by tenderlovemaking (Aaron Patterson) 2 months ago. Updated 2 months ago.

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

Description

When you remove the allocate method from a class the you can't allocate the class via the allocate method. However, you can allocate the class via the new method:

class Foo; end

Foo.singleton_class.undef_method(:allocate)

begin
  Foo.allocate # doesn't work, of course
rescue NoMethodError
end

begin
  Class.instance_method(:allocate).bind_call(Foo) # also doesn't work
rescue TypeError
end

Foo.new # works?

I think that when we remove the allocate method, the new method should also fail as there is no allocate method for new to call.

Actions

Also available in: Atom PDF

Like1
Like0Like0Like1