[#101179] Spectre Mitigations — Amel <amel.smajic@...>
Hi there!
5 messages
2020/12/01
[#101694] Ruby 3.0.0 Released — "NARUSE, Yui" <naruse@...>
V2UgYXJlIHBsZWFzZWQgdG8gYW5ub3VuY2UgdGhlIHJlbGVhc2Ugb2YgUnVieSAzLjAuMC4gRnJv
4 messages
2020/12/25
[ruby-core:101293] [Ruby master Bug#17374] Refined methods aren't visible from a refinement's module
From:
merch-redmine@...
Date:
2020-12-07 20:31:33 UTC
List:
ruby-core #101293
Issue #17374 has been updated by jeremyevans0 (Jeremy Evans).
I do not think this is a bug. The question to ask yourself is, at the point of call, is the refinement active?. So in method `Implementation#foo`, we are talking about the call to `bar`:
```ruby
def foo
super(bar) # << Can not see bar
end
```
No, the refinement is not active at that point. You can make it active, though doing so is probably not obvious:
```ruby
class Foo
module Extension
module Implementation
end
refine Foo do
prepend Implementation
end
module Implementation
def foo
super(bar) # << Can not see bar
end
def bar # << Bar is in the same module!
42
end
end
end
def foo(value = :none)
p value
end
end
Foo.new
Foo.new.foo # => :none (ok)
# Does not work: undefined local variable or method `bar'
using Foo::Extension
Foo.new.foo rescue (p :error) # => :error
# Works:
Foo.send(:prepend, Foo::Extension::Implementation)
Foo.new.foo # => 42
```
This is because `refine` implicitly activates the refinement, so the refinement is active at the point `bar` is called. This approach works back to Ruby 2.0, with output:
```
:none
:none
42
```
----------------------------------------
Bug #17374: Refined methods aren't visible from a refinement's module
https://bugs.ruby-lang.org/issues/17374#change-88977
* Author: marcandre (Marc-Andre Lafortune)
* Status: Open
* Priority: Normal
* Assignee: shugo (Shugo Maeda)
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>