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-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-2.9 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_PASS shortcircuit=no autolearn=no 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 D17E220248 for ; Sun, 10 Mar 2019 00:44:55 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id BFC62121CF3; Sun, 10 Mar 2019 09:44:51 +0900 (JST) Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id E3AA312154F for ; Sun, 10 Mar 2019 09:44:49 +0900 (JST) Received: by filter0056p3las1.sendgrid.net with SMTP id filter0056p3las1-15703-5C845DFD-1A 2019-03-10 00:44:45.885426795 +0000 UTC m=+88036.947095301 Received: from herokuapp.com (unknown [3.87.95.71]) by ismtpd0038p1iad2.sendgrid.net (SG) with ESMTP id tQk95CsxTW2lIGAVHXw5Gg for ; Sun, 10 Mar 2019 00:44:45.729 +0000 (UTC) Date: Sun, 10 Mar 2019 00:44:46 +0000 (UTC) From: alanwucanada@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 67182 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15646 X-Redmine-Issue-Author: alanwu X-Redmine-Sender: alanwu 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?jxWKqnXOckdYE3zELIumel1PrOP8HeovWI9f2iebhlmxmZVvz7DZ8rsVfFx5j5?= =?us-ascii?Q?pcDZE8kmmHzhy6GYSwmXAQb2H4ocaxkmUJ7koQN?= =?us-ascii?Q?BvBAtNwAtrBs3G0rIWiWEC7+fJvdQ5PzEuNYurb?= =?us-ascii?Q?EG9YwtG7NjQgArylcawltJHsrZfbS2p+P1IbHs2?= =?us-ascii?Q?CZAUNI9XQofd9B6ZOiz7YoGuRSujVWXXRDA=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 91732 Subject: [ruby-core:91732] [Ruby trunk Bug#15646] method_defined? inside method_added behaves differently for `initialize` 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 #15646 has been updated by alanwu (Alan Wu). This behavior is from [Feature #6539]. Do you remember why these methods are made to be always private, instead of setting them to be private in Kernel only? I don't think this rule make sense for BasicObject classes since they don't have `#dup` and `#clone` and `#respond_to?`: ```ruby class A < BasicObject public def initialize_dup end end A.new.initialize_dup # private method `initialize_dup' called ``` ---------------------------------------- Bug #15646: method_defined? inside method_added behaves differently for `initialize` https://bugs.ruby-lang.org/issues/15646#change-77008 * Author: alanwu (Alan Wu) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.7.0dev (2019-03-08 trunk 67194) [x86_64-darwin18] * Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- Repro: ```ruby class MethodAddedSpecialCase def self.method_added(name) puts "#{name} added, method_defined?: #{method_defined?(name)}" end def hello end def initialize end def world end end ``` Output: ``` hello added, method_defined?: true initialize added, method_defined?: false world added, method_defined?: true ``` -- https://bugs.ruby-lang.org/