[#116016] [Ruby master Bug#20150] Memory leak in grapheme clusters — "peterzhu2118 (Peter Zhu) via ruby-core" <ruby-core@...>
Issue #20150 has been reported by peterzhu2118 (Peter Zhu).
7 messages
2024/01/04
[#116382] [Ruby master Feature#20205] Enable `frozen_string_literal` by default — "byroot (Jean Boussier) via ruby-core" <ruby-core@...>
Issue #20205 has been reported by byroot (Jean Boussier).
77 messages
2024/01/23
[ruby-core:116270] [Ruby master Bug#20188] `Module#const_source_location` returns wrong information when real constant was defined but autoload is still ongoing
From:
"fxn (Xavier Noria) via ruby-core" <ruby-core@...>
Date:
2024-01-17 09:40:08 UTC
List:
ruby-core #116270
Issue #20188 has been updated by fxn (Xavier Noria).
I tried, the current behavior does not make a lot of sense to me:
```ruby
File.write('/tmp/bar.rb', 'Bar = 1; raise')
autoload :Bar, '/tmp/bar'
Bar rescue nil
p Object.const_source_location(:Bar) # ["foo.rb", 2]
p Object.autoload?(:Bar) # "/tmp/bar"
p Bar # raises
```
In Ruby, an `autoload` is a trigger, you are not even required to define the constant in the receiver. The autoload was triggered, therefore, in my view it should be gone. I would expect:
```ruby
p Object.const_source_location(:Bar) # ["/tmp/bar.rb", 1]
p Object.autoload?(:Bar) # nil
p Bar # 1
```
Regarding the first sentence, here's an autoload that does not define a constant. It is just a trigger:
```ruby
module M
Bar = 1
end
class Object
include M
end
File.write('/tmp/bar.rb', '')
autoload :Bar, '/tmp/bar'
Bar
p Object.const_source_location(:Bar) # ["foo.rb", 2]
p Object.autoload?(:Bar) # nil
p Bar # 1
```
Could it be the case that the internal "housekeeping" just does not get a chance because the exeption bubbles up?
----------------------------------------
Bug #20188: `Module#const_source_location` returns wrong information when real constant was defined but autoload is still ongoing
https://bugs.ruby-lang.org/issues/20188#change-106292
* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
Ref: https://github.com/fxn/zeitwerk/issues/281
`const_source_location` keeps returning the location of the `autoload` call, even after the real constant was defined. It only starts returning the real constant location once the autoload was fully completed.
```ruby
# /tmp/autoload.rb
File.write("/tmp/const.rb", <<~RUBY)
module Const
LOCATION = Object.const_source_location(:Const)
end
RUBY
autoload :Const, "/tmp/const"
p Const::LOCATION
```
Expected Output:
```ruby
["/tmp/const.rb", 1]
```
Actual Output:
```ruby
["/tmp/autoload.rb", 8]
```
Potential patch: https://github.com/ruby/ruby/pull/9549
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/