* [ruby-core:96809] [Ruby master Bug#16506] Documentation for `Module#const_souce_location` is wrong
[not found] <redmine.issue-16506.20200112181728@ruby-lang.org>
@ 2020-01-12 18:17 ` sawadatsuyoshi
2020-01-12 18:40 ` [ruby-core:96812] " zverok.offline
` (3 subsequent siblings)
4 siblings, 0 replies; 5+ messages in thread
From: sawadatsuyoshi @ 2020-01-12 18:17 UTC (permalink / raw)
To: ruby-core
Issue #16506 has been reported by sawa (Tsuyoshi Sawada).
----------------------------------------
Bug #16506: Documentation for `Module#const_souce_location` is wrong
https://bugs.ruby-lang.org/issues/16506
* 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.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ruby-core:96812] [Ruby master Bug#16506] Documentation for `Module#const_souce_location` is wrong
[not found] <redmine.issue-16506.20200112181728@ruby-lang.org>
2020-01-12 18:17 ` [ruby-core:96809] [Ruby master Bug#16506] Documentation for `Module#const_souce_location` is wrong sawadatsuyoshi
@ 2020-01-12 18:40 ` zverok.offline
2020-01-12 18:41 ` [ruby-core:96814] " zverok.offline
` (2 subsequent siblings)
4 siblings, 0 replies; 5+ messages in thread
From: zverok.offline @ 2020-01-12 18:40 UTC (permalink / raw)
To: ruby-core
Issue #16506 has been updated by zverok (Victor Shepelev).
@sawa That's an interesting question! I wrote an original doc, and I meant this:
```ruby
# test.rb:
class A
end
class A # reopening
end
Object.const_source_location('A') # => ["test.rb", 1] -- first definition
```
But of course, if we are talking about plain constants (not classes), you are right:
```ruby
# test.rb:
A = 1
A = 2
Object.const_source_location('A') # => ["test.rb", 3] -- LAST definition
```
I'll submit a PR with clarifications to cover both cases.
----------------------------------------
Bug #16506: Documentation for `Module#const_souce_location` is wrong
https://bugs.ruby-lang.org/issues/16506#change-83807
* 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/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ruby-core:96814] [Ruby master Bug#16506] Documentation for `Module#const_souce_location` is wrong
[not found] <redmine.issue-16506.20200112181728@ruby-lang.org>
2020-01-12 18:17 ` [ruby-core:96809] [Ruby master Bug#16506] Documentation for `Module#const_souce_location` is wrong sawadatsuyoshi
2020-01-12 18:40 ` [ruby-core:96812] " zverok.offline
@ 2020-01-12 18:41 ` zverok.offline
2020-01-19 11:51 ` [ruby-core:96943] " zverok.offline
2020-01-23 17:26 ` [ruby-core:96985] " merch-redmine
4 siblings, 0 replies; 5+ messages in thread
From: zverok.offline @ 2020-01-12 18:41 UTC (permalink / raw)
To: ruby-core
Issue #16506 has been updated by zverok (Victor Shepelev).
Ah, while I was writing the comment, you've updated the description with the same thoughts :)
Will fix.
----------------------------------------
Bug #16506: Documentation for `Module#const_souce_location` is wrong
https://bugs.ruby-lang.org/issues/16506#change-83809
* 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/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ruby-core:96943] [Ruby master Bug#16506] Documentation for `Module#const_souce_location` is wrong
[not found] <redmine.issue-16506.20200112181728@ruby-lang.org>
` (2 preceding siblings ...)
2020-01-12 18:41 ` [ruby-core:96814] " zverok.offline
@ 2020-01-19 11:51 ` zverok.offline
2020-01-23 17:26 ` [ruby-core:96985] " merch-redmine
4 siblings, 0 replies; 5+ messages in thread
From: zverok.offline @ 2020-01-19 11:51 UTC (permalink / raw)
To: 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/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ruby-core:96985] [Ruby master Bug#16506] Documentation for `Module#const_souce_location` is wrong
[not found] <redmine.issue-16506.20200112181728@ruby-lang.org>
` (3 preceding siblings ...)
2020-01-19 11:51 ` [ruby-core:96943] " zverok.offline
@ 2020-01-23 17:26 ` merch-redmine
4 siblings, 0 replies; 5+ messages in thread
From: merch-redmine @ 2020-01-23 17:26 UTC (permalink / raw)
To: ruby-core
Issue #16506 has been updated by jeremyevans0 (Jeremy Evans).
Status changed from Open to Closed
Fixed by commit:2bde7919a0a8302c344e9bb9ddc217958fcbd3c7
----------------------------------------
Bug #16506: Documentation for `Module#const_souce_location` is wrong
https://bugs.ruby-lang.org/issues/16506#change-84042
* Author: sawa (Tsuyoshi Sawada)
* Status: Closed
* 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/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-01-23 17:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <redmine.issue-16506.20200112181728@ruby-lang.org>
2020-01-12 18:17 ` [ruby-core:96809] [Ruby master Bug#16506] Documentation for `Module#const_souce_location` is wrong sawadatsuyoshi
2020-01-12 18:40 ` [ruby-core:96812] " zverok.offline
2020-01-12 18:41 ` [ruby-core:96814] " zverok.offline
2020-01-19 11:51 ` [ruby-core:96943] " zverok.offline
2020-01-23 17:26 ` [ruby-core:96985] " merch-redmine
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).