Project

General

Profile

Actions

Feature #18270

open

Refinement#{extend_object,append_features,prepend_features} should be removed

Added by shugo (Shugo Maeda) about 1 month ago. Updated 17 days ago.

Status:
Assigned
Priority:
Normal
Target version:
-
[ruby-core:105805]

Description

Refinement#{extend_object,append_features,prepend_features} are not useful and should be removed.

How about to deprecate them in Ruby 3.1 and remove in Ruby 3.1?


Related issues

Related to Ruby master - Bug #17429: Prohibit include/prepend in refinement modulesClosedshugo (Shugo Maeda)Actions
Actions #1

Updated by shugo (Shugo Maeda) about 1 month ago

  • Related to Bug #17429: Prohibit include/prepend in refinement modules added
Actions #2

Updated by jeremyevans0 (Jeremy Evans) about 1 month ago

  • Backport deleted (2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN)
  • Tracker changed from Bug to Feature

Updated by shugo (Shugo Maeda) 19 days ago

These methods raise ArgumentError since #13236 was fixed, so it may not be necessary to remove them.

Updated by shugo (Shugo Maeda) 19 days ago

append_features is undefined in the class Class, and Module#include raises TypeError before calling append_features if the given argument is a Class.

Updated by shugo (Shugo Maeda) 18 days ago

  • Assignee changed from matz (Yukihiro Matsumoto) to shugo (Shugo Maeda)

At the developers meeting on 2011-11-18, Matz accepted the following changes in Ruby 3.2:

  • Undefine extend_object, append_features, prepend_features in Refinement.
  • extend, include, and prepend raise a TypeError if the given argument is a Refinement as in the case the argument is a Class.

No warnings will be added in Ruby 3.1, because append_features etc. currently already raises ArgumentError.

excelsior:ruby$ ruby -e 'class Foo; end; module Bar; refine Integer do append_features(Foo); end; end'
-e:1:in `append_features': refinement module is not allowed (ArgumentError)
        from -e:1:in `block in <module:Bar>'
        from -e:1:in `refine'
        from -e:1:in `<module:Bar>'
        from -e:1:in `<main>'

Updated by Eregon (Benoit Daloze) 18 days ago

Sounds good.
Could you please add tests in ruby/spec to track those changes, under core/refinement?
The structure can be generated with ../mspec/bin/mkspec -b core -c Refinement.

Updated by shugo (Shugo Maeda) 17 days ago

Eregon (Benoit Daloze) wrote in #note-6:

Sounds good.

Thanks.

Could you please add tests in ruby/spec to track those changes, under core/refinement?
The structure can be generated with ../mspec/bin/mkspec -b core -c Refinement.

OK, I'll add tests after implementing these changes after the release of Ruby 3.1.

Actions

Also available in: Atom PDF