[#111472] [Ruby master Bug#19274] Error installing ruby 3.2.0 on RH 8 — "aalllop (Alberto Allegue) via ruby-core" <ruby-core@...>
Issue #19274 has been reported by aalllop (Alberto Allegue).
5 messages
2022/12/28
[#111508] Data support for versions before 3.2.0 — Eustáquio Rangel via ruby-core <ruby-core@...>
I was wondering that every piece of code (gems, etc) that use the new Data =
3 messages
2022/12/29
[ruby-core:111451] [Ruby master Bug#19269] Constant lookup and #instance_eval
From:
"andrykonchin (Andrew Konchin) via ruby-core" <ruby-core@...>
Date:
2022-12-27 12:22:13 UTC
List:
ruby-core #111451
Issue #19269 has been reported by andrykonchin (Andrew Konchin).
----------------------------------------
Bug #19269: Constant lookup and #instance_eval
https://bugs.ruby-lang.org/issues/19269
* Author: andrykonchin (Andrew Konchin)
* Status: Open
* Priority: Normal
* ruby -v: 3.1.3
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
I've noticed a confusing behaviour of `#instance_eval` (and `#instance_exec` as well). In some cases it doesn't see constants defined in the object class.
Examples:
```ruby
C = 1
class A
C = 2
end
```
When `#instance_eval` is called with a String - `A::C` constant is visible, that is pretty expected:
```ruby
A.new.instance_eval("C") # => 2
```
But when it's called with a block - `A::C` isn't visible:
```ruby
A.new.instance_eval { C } # => 1
```
If we define a method that returns a constant (defined in the class), then `A::C` is visible in both cases:
```ruby
C = 1
class A
C = 2
def c; C; end
end
A.new.instance_eval("c") # => 2
A.new.instance_eval { c } # => 2
```
So we see that when `#instance_eval` called with a block and a constant is assessed directly is the only case when a class constant isn't visible.
Wondering whether it's an expected behaviour and the reason to behave this way.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- [email protected]
To unsubscribe send an email to [email protected]
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/