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.6 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_HELO_NONE,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 8C8A71F466 for ; Sun, 19 Jan 2020 11:51:28 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id C654C120932; Sun, 19 Jan 2020 20:51:10 +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 F0EB3120931 for ; Sun, 19 Jan 2020 20:51:07 +0900 (JST) Received: by filterdrecv-p3iad2-57f487d66-l92zz with SMTP id filterdrecv-p3iad2-57f487d66-l92zz-17-5E2442B3-30 2020-01-19 11:51:15.700548943 +0000 UTC m=+2891077.113121088 Received: from herokuapp.com (unknown [3.81.21.207]) by ismtpd0028p1iad2.sendgrid.net (SG) with ESMTP id i1zeh-c_TJidHhTOIZTeTg for ; Sun, 19 Jan 2020 11:51:15.545 +0000 (UTC) Date: Sun, 19 Jan 2020 11:51:15 +0000 (UTC) From: zverok.offline@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 72608 X-Redmine-Project: ruby-master X-Redmine-Issue-Id: 16506 X-Redmine-Issue-Author: sawa X-Redmine-Sender: zverok 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?3be0g8093pjUjT94eiCA64csFDBI=2FmHQTWm54P5gda6KqfOvjKELgTl1ss=2FkcY?= =?us-ascii?Q?cFtdO=2FbETvmcCOqXqQgvrFuOgwIOv4kvVzcjh1y?= =?us-ascii?Q?jPbHT3jW6D=2F5++gVSsfNRzXjvnGueMg4cpLDmik?= =?us-ascii?Q?XCjxOtIsZdBclN2QegBhXDFhGxc4a0q5sV4mjQO?= =?us-ascii?Q?f0u9lgbDDD6aiWPcxCUIUojDAfZsfQxENUEF03W?= =?us-ascii?Q?dHItu5woSt+s=2FEoq8=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 96943 Subject: [ruby-core:96943] [Ruby master Bug#16506] Documentation for `Module#const_souce_location` is wrong 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 #16506 has been updated by zverok (Victor Shepelev). Clarification PR: https://github.com/ruby/ruby/pull/2850 ---------------------------------------- Bug #16506: Documentation for `Module#const_souce_location` is wrong https://bugs.ruby-lang.org/issues/16506#change-83970 * Author: sawa (Tsuyoshi Sawada) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: 2.7 * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- https://ruby-doc.org/core-2.7.0/Module.html#method-i-const_source_location says: > Returns the Ruby source filename and line number containing **first** definition of constant specified. It should be: > Returns the Ruby source filename and line number containing the **last** definition (the effective definition) of the constant specified. It also has an example line: ```ruby p Object.const_source_location('A') # => ["test.rb", 1] -- note it is first entry, not "continuation" ``` but that may give the impression that the first-ness is due to the nature of this method. The reason `["test.rb", 1]` is returned instead of `["test.rb", 14]` is because the constant is created at line 1, and is only reopened/modified in line 14. Perhaps, this line can be changed to: ```ruby p Object.const_source_location('A') # => ["test.rb", 1] -- note 'A' is created in line 1, and is only reopened/modified in "continuation" ``` Adding something like this may make it clear that it is the last definition that is returned: ```ruby D = 'D1' D = 'D2' D = 'D3' ... Object.const_source_location('D') # => returns the location that corresponds to 'D3' -- https://bugs.ruby-lang.org/