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=-4.1 required=3.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_PASS 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 23F5620248 for ; Sun, 10 Mar 2019 16:41:17 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 5B3FE121EEF; Mon, 11 Mar 2019 01:41:13 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id C8E4D120C97 for ; Mon, 11 Mar 2019 01:41:10 +0900 (JST) Received: by filter0021p3iad2.sendgrid.net with SMTP id filter0021p3iad2-19115-5C853E0D-10 2019-03-10 16:40:45.502869124 +0000 UTC m=+145352.688574064 Received: from herokuapp.com (unknown [54.173.53.240]) by ismtpd0025p1iad2.sendgrid.net (SG) with ESMTP id an2g65Z1TpKogi8G8W0Llw for ; Sun, 10 Mar 2019 16:40:45.632 +0000 (UTC) Date: Sun, 10 Mar 2019 16:41:10 +0000 (UTC) From: mame@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 67187 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15627 X-Redmine-Issue-Author: sawa X-Redmine-Sender: mame 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?EJh2gqwnyqXtd++xo=2FinyA1V0bXouTB4FkWnzNiKb4+kL=2Fg=2F6bZN5gVHj=2Fy4Fs?= =?us-ascii?Q?gxX1lM7HoVZhhHImC445Zge4hdb1ACYti2F4GlS?= =?us-ascii?Q?GCBTiV1uMWncG+l54PW3MMAkg6vWMYypZHKFBC6?= =?us-ascii?Q?L21oHjyRYPOEQSY+YIbx27iqzcl3OMau970jBs8?= =?us-ascii?Q?RwNfhd+CoLSZXh6O9YUfBOcQMklUDRLw66Q=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 91737 Subject: [ruby-core:91737] [Ruby trunk Bug#15627] Appearance of custom singleton classes 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 #15627 has been updated by mame (Yusuke Endoh). Wow. ``` def true.foo; end p TrueClass.instance_methods.include?(:foo) #=> true ``` I didn't know, thanks. I have used Ruby for fifteen years, but Ruby still brings fresh surprise to me. ---------------------------------------- Bug #15627: Appearance of custom singleton classes https://bugs.ruby-lang.org/issues/15627#change-77013 * Author: sawa (Tsuyoshi Sawada) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: * Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- When I have a singleton class `AClass` of an instance `a` of a custom class `A`, ```ruby class A; end a = A.new AClass = a.singleton_class ``` i) even though the singleton class of `nil`, `false`, and `true` are referred to by their assigned constant names, the singleton class `AClass` of `a` is not: ```ruby nil.singleton_class #=> NilClass false.singleton_class #=> FalseClass true.singleton_class #=> TrueClass a.singleton_class #=> #> ``` ii) even though the singleton class of `nil`, `false`, and `true` appear as their class, the singleton class `AClass` of `a` does not: ```ruby nil.class #=> NilClass false.class #=> FalseClass true.class #=> TrueClass a.class #=> A ``` This contrast between `nil`, `false`, and `true` on the one hand and `a` on the other is confusing. I am actually not sure if this is intended behaviour It may be related to * https://bugs.ruby-lang.org/issues/15608 * https://bugs.ruby-lang.org/issues/14895 I expect `AClass` to behave the same as with `NilClass`, `FalseClass`, and `TrueClass`. I expect: ```ruby a.singleton_class #=> AClass a.class #=> AClass ``` If the current behaviour is intended, I would like this to become a feature request. -- https://bugs.ruby-lang.org/