[#118346] [Ruby master Bug#20586] Some filesystem calls in dir.c are missing error handling and can return incorrect results if interrupted — "ivoanjo (Ivo Anjo) via ruby-core" <ruby-core@...>
Issue #20586 has been reported by ivoanjo (Ivo Anjo).
13 messages
2024/06/19
[ruby-core:118194] [Ruby master Bug#18622] const_get still looks in Object, while lexical constant lookup no longer does
From:
"matz (Yukihiro Matsumoto) via ruby-core" <ruby-core@...>
Date:
2024-06-06 05:26:33 UTC
List:
ruby-core #118194
Issue #18622 has been updated by matz (Yukihiro Matsumoto).
Status changed from Open to Closed
Sorry, I forgot to reply. Due to the compatibility concern, I'd like to keep this behavior even though it's inconsistent with direct constant accesses.
Matz.
----------------------------------------
Bug #18622: const_get still looks in Object, while lexical constant lookup no longer does
https://bugs.ruby-lang.org/issues/18622#change-108677
* Author: Eregon (Benoit Daloze)
* Status: Closed
* ruby -v: ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
There is some inconsistency here between literal constant lookup and the meta API (const_get).
Lexical constant lookup no longer uses a special case for Object, and this is good as it avoids surprises: #11547
However, `const_get` still looks in Object, even though that's confusing, inconsistent and IMHO shouldn't really happen.
```ruby
module ConstantSpecsTwo
Foo = :cs_two_foo
end
module ConstantSpecs
end
p ConstantSpecs.const_get("ConstantSpecsTwo::Foo") # => :cs_two_foo
p ConstantSpecs::ConstantSpecsTwo::Foo # => const_get.rb:9:in `<main>': uninitialized constant ConstantSpecs::ConstantSpecsTwo (NameError)
```
I think we should change it so both behave the same (i.e., NameError).
It's like if `cd /foo/bar` would go to `/bar` if `/foo/bar` does not exist and `/bar` does.
`const_get` is a meta API so it cannot know the surrounding `Module.nesting`, but so I think it should consider the receiver of `const_get` as the only nesting (so just `ConstantSpecs` in this case, not `Object`).
Note this does not affect nested constants inside the `const_get` like `Foo` above (another way to look at the inconsistency that the first component is treated differently).
>From https://bugs.ruby-lang.org/issues/11547#note-19
--
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/