From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 84E361F9FD for ; Tue, 16 Mar 2021 17:34:23 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id F0CB4120A73; Wed, 17 Mar 2021 02:33:23 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 2BF2B120A6C for ; Wed, 17 Mar 2021 02:33:21 +0900 (JST) Received: by filterdrecv-p3las1-c477c4585-l5jzx with SMTP id filterdrecv-p3las1-c477c4585-l5jzx-19-6050EC18-76 2021-03-16 17:34:16.686226406 +0000 UTC m=+3005190.369779631 Received: from herokuapp.com (unknown) by ismtpd0169p1iad2.sendgrid.net (SG) with ESMTP id 2uisxKmqRvaFAdjCY83hQA for ; Tue, 16 Mar 2021 17:34:16.493 +0000 (UTC) Date: Tue, 16 Mar 2021 17:34:16 +0000 (UTC) From: josh@thereedfamily.rocks Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 78920 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 17725 X-Redmine-Issue-Author: joshuadreed X-Redmine-Sender: joshuadreed X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?=2F0TKmnSpRKQ3qEyk61=2FcmDyYTjlfQgpx5DdbWSMvDfbSQ8HE1DTRKXQFqsHXdl?= =?us-ascii?Q?m+G0yaJuORsqulJgXKix1rSCw1feJFtGKq9e0im?= =?us-ascii?Q?TusuHu5UZCN8yoEWdUipHWagPJSorQt2fuBS8p+?= =?us-ascii?Q?m9=2Fk9NuHxYc3vDXkTLkHk8NYMQ5HWBo3V0vceyv?= =?us-ascii?Q?eh7OjFOj5Nm8b6q7udHB3H278NC8xkFDK0NkaRi?= =?us-ascii?Q?SrFkRUN1YCdcPYFXk=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 102885 Subject: [ruby-core:102885] [Ruby master Bug#17725] Prepend Breaks Ability to Alias X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #17725 has been updated by joshuadreed (Josh Reed). ``` ruby module Dummy; end class Foo def ten 10 end end Foo.prepend(Dummy) class Foo alias_method(:old_ten, :ten) def ten puts 'blah blah' old_ten end end Foo.new.ten > blah blah ``` Okay, doesn't seem to affect *every* class. I do suspect it may be to do with refinement, so I will check into that next. ---------------------------------------- Bug #17725: Prepend Breaks Ability to Alias https://bugs.ruby-lang.org/issues/17725#change-90945 * Author: joshuadreed (Josh Reed) * Status: Open * Priority: Normal * ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- Prepending any module to `String` and `Hash` (and possibly other or all classes?) blocks the ability to `alias` As an example: ``` ruby module Dummy; end # String.prepend(Dummy) class String alias_method(:old_plus, :+) def + other puts 'blah blah' old_plus(other) end end 'a' + 'b' > blah blah ``` ``` ruby module Dummy; end String.prepend(Dummy) class String alias_method(:old_plus, :+) def + other puts 'blah blah' old_plus(other) end end 'a' + 'b' > ``` Prepending after an `alias` does not affect the previous `alias` -- https://bugs.ruby-lang.org/