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, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,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 E53F61F462 for ; Sat, 25 May 2019 03:40:46 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 455891208FA; Sat, 25 May 2019 12:40:39 +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 961A2120B5A for ; Sat, 25 May 2019 12:40:36 +0900 (JST) Received: by filter0060p3iad2.sendgrid.net with SMTP id filter0060p3iad2-11345-5CE8B935-B 2019-05-25 03:40:37.335073258 +0000 UTC m=+122587.378763615 Received: from herokuapp.com (unknown [35.175.245.114]) by ismtpd0020p1iad2.sendgrid.net (SG) with ESMTP id xhmX7tJlSdOZJBJfox8jTQ for ; Sat, 25 May 2019 03:40:37.098 +0000 (UTC) Date: Sat, 25 May 2019 03:40:37 +0000 (UTC) From: merch-redmine@jeremyevans.net Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 68322 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15875 X-Redmine-Issue-Author: matsuda X-Redmine-Sender: jeremyevans0 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?RVE3t853K5scBhbmJHUzZTFFeVC=2FZSUmHZ0Dc+26wcEi2CTgsF1oz0wTSSxGGN?= =?us-ascii?Q?BIOSthZ1=2FFdTx11XqD+gXEVAcy4woa2S+OHiUvr?= =?us-ascii?Q?wl9rTKS5OEAyOFl1zUCfyDytlBLQFmeXgLIBUc6?= =?us-ascii?Q?QeoQnigdHREtKRpCay5YF=2FI6cpF7TY76b4ulHLR?= =?us-ascii?Q?rRBJaDKvV3+Q+cOoyEuskax1DuBvH70Z5wg=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 92839 Subject: [ruby-core:92839] [Ruby trunk Bug#15875] const_defined? behavior inconsistency in 2.6.x series 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 #15875 has been updated by jeremyevans0 (Jeremy Evans). Bisected to commit:bf8cc37b467e1d372e1b01b4d25e9ef6f8cc927f. Backporting commit:d10451f3fd51f577e704db770de48d05044eb45c to 2.6 fixes this bug. ---------------------------------------- Bug #15875: const_defined? behavior inconsistency in 2.6.x series https://bugs.ruby-lang.org/issues/15875#change-78218 * Author: matsuda (Akira Matsuda) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: 2.6.1, 2.6.2, 2.6.3 * Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- `Module#const_defined?` returns true for unreachable nested fully qualified module name. Here are the results of `const_defined?` for each ruby version on my machine. ``` % ruby -e "module A; end; B = 1; p Object.const_defined?('A::B')" [1.9.3-p551, 2.0.0-p648] -e:1:in `const_defined?': wrong constant name A::B (NameError) from -e:1:in `
' [2.1.10, 2.2.10, 2.3.8, 2.4.6, 2.5.5, 2.6.0] false [2.6.1, 2.6.2, 2.6.3] true [2.7.0-dev (2019-05-25 trunk 559dca509d)] false ``` For (2.6.1...2.6.3), it fails to reference the constant even though `const_defined?` returns true. So IMO this should be `const_defined?`'s bug. ``` % ruby -e "module A; end; B = 1; p Object.const_defined?('A::B') && A::B" -e:1:in `
': uninitialized constant A::B (NameError) ``` -- https://bugs.ruby-lang.org/