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=-4.1 required=3.0 tests=AWL,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,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 96E041F55B for ; Tue, 2 Jun 2020 10:01:32 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 65E881209EF; Tue, 2 Jun 2020 19:01:05 +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 7E6D61209E4 for ; Tue, 2 Jun 2020 19:01:03 +0900 (JST) Received: by filterdrecv-p3mdw1-6dbfd75bfd-rd7m8 with SMTP id filterdrecv-p3mdw1-6dbfd75bfd-rd7m8-20-5ED62370-10C 2020-06-02 10:01:20.974856469 +0000 UTC m=+5907241.487366770 Received: from herokuapp.com (unknown) by ismtpd0054p1iad1.sendgrid.net (SG) with ESMTP id 6ETkb9GEQJi25127XSjaGA for ; Tue, 02 Jun 2020 10:01:20.892 +0000 (UTC) Date: Tue, 02 Jun 2020 10:01:21 +0000 (UTC) From: nobu@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 74415 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 16931 X-Redmine-Issue-Author: nobu X-Redmine-Sender: nobu 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?q8Dly+pU2+3ektTtZVXgZtbJPXwqo7p86jCsvYTW4Bx3U8whwLyK3nfQYfUkX1?= =?us-ascii?Q?ZesH8BdzRAov++0CYGuQ9tTYgbdiQ8UhI5pydzp?= =?us-ascii?Q?dAJRnvZyS4MOkuzNPszqtIPqMKxO6UucEnKnyqL?= =?us-ascii?Q?c4bv1fudF5aFBTLbRw+HPVBaIhkD2ofW9tY4a2S?= =?us-ascii?Q?y9iQoHZ1jI2opav02z5d2fGrSV+2jFRsfsanelP?= =?us-ascii?Q?VfpUVsEchvuu3Grzs=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 98624 Subject: [ruby-core:98624] [Ruby master Bug#16931] `defined?` against a protected method call on an inherited instance returns wrong `nil` 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 #16931 has been reported by nobu (Nobuyoshi Nakada). ---------------------------------------- Bug #16931: `defined?` against a protected method call on an inherited instance returns wrong `nil` https://bugs.ruby-lang.org/issues/16931 * Author: nobu (Nobuyoshi Nakada) * Status: Open * Priority: Normal * ruby -v: 2.8.0dev (2020-06-02T08:21:03Z master 56ca006784) * Backport: 2.5: REQUIRED, 2.6: REQUIRED, 2.7: REQUIRED ---------------------------------------- The following code shows `:callable` first, but `nil` next, since 1.9. If the method is callable, `defined?` expression has to return truthy value. ``` ruby class A def foo :callable end protected :foo def t(x) x.foo end def q(x) defined?(x.foo) end end class B :callable p a.q(b) #=> nil ``` -- https://bugs.ruby-lang.org/