[#88925] [Ruby trunk Feature#15095] [PATCH] share VM stack between threads and fibers if identical — ko1@...
Issue #15095 has been updated by ko1 (Koichi Sasada).
4 messages
2018/09/09
[#88927] Re: [Ruby trunk Feature#15095] [PATCH] share VM stack between threads and fibers if identical
— Eric Wong <normalperson@...>
2018/09/09
[email protected] wrote:
[#88926] [Ruby trunk Feature#15095] [PATCH] share VM stack between threads and fibers if identical — ko1@...
Issue #15095 has been updated by ko1 (Koichi Sasada).
3 messages
2018/09/09
[#89218] [Ruby trunk Bug#15130] open-uri hangs on cygwin — duerst@...
SXNzdWUgIzE1MTMwIGhhcyBiZWVuIHVwZGF0ZWQgYnkgZHVlcnN0IChNYXJ0aW4gRMO8cnN0KS4K
5 messages
2018/09/30
[ruby-core:89064] [Ruby trunk Bug#15135][Closed] Refining #initialize method not working
From:
matz@...
Date:
2018-09-18 12:49:16 UTC
List:
ruby-core #89064
Issue #15135 has been updated by matz (Yukihiro Matsumoto).
Status changed from Open to Closed
From the reference (https://docs.ruby-lang.org/en/2.5.0/syntax/refinements_rdoc.html):
>Refinements are lexical in scope.
>When control is transferred outside the scope, the refinement is deactivated. This means that if you require or load a file or call a method that is defined outside the current scope the refinement will be deactivated
So `initialize` which is called outside of the scope will not be overridden.
Matz.
----------------------------------------
Bug #15135: Refining #initialize method not working
https://bugs.ruby-lang.org/issues/15135#change-74087
* Author: cbruckmayer (Christian Bruckmayer)
* Status: Closed
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.5.0p0 (2017-12-25 revision 61468)
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
See the following example:
```
class C
def initialize(arg)
puts arg
end
end
module M
refine C do
def initialize(arg1, arg2)
puts arg1, arg2
end
end
end
using M
C.new("foo") # works
C.new("foo", "bar") # wrong number of arguments (given 2, expected 1) (ArgumentError)
```
This code will throw an ``refinement.rb:2:in `initialize': wrong number of arguments (given 2, expected 1) (ArgumentError)`` exception. I would expect that it is possible to refine the initialize method to have similar behavior as monkey patching. If this is intended behavior I would at least expect this to be documented here: https://docs.ruby-lang.org/en/2.5.0/syntax/refinements_rdoc.html
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>