[#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:88801] [Ruby trunk Bug#15027] When Struct#each method is overriden Struct#select and Struct#to_a use wrong collections
From:
ruby-lang@...
Date:
2018-09-01 16:14:25 UTC
List:
ruby-core #88801
Issue #15027 has been updated by bruno (Bruno Sutic).
File struct_enumerable_fix2.patch added
Thank you for the code @nobu. I have applied Nobu's suggestion, please find updated patch in the attach.
> If you can override each, you can override other methods.
This is true, but doing this is very un-ruby-ish. Also, I don't think an average ruby developer will be patient enough to investigate why is this happening. A more realistic scenario is that a developer will just implement a custom `#select` or `#to_a` method.
----------------------------------------
Bug #15027: When Struct#each method is overriden Struct#select and Struct#to_a use wrong collections
https://bugs.ruby-lang.org/issues/15027#change-73841
* Author: bruno (Bruno Sutic)
* Status: Feedback
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: 2.6.0dev
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
### Bug
Here's the code snippet that should reproduce the problem:
~~~ ruby
class Foo < Struct.new(:bar)
def each(&block)
[:baz, :qux].each(&block)
end
end
foo = Foo.new(:foo)
foo.map(&:itself) # => [:baz, :qux] # OK
foo.to_a # => [:foo] # NOT OK, expected [:baz, :qux]
foo.select(&:itself) # => [:foo] # NOT OK, expected [:baz, :qux]
~~~
As you can see, even tho we defined another collection for use by overriding `#each`, the `to_a` and `select` still use `Struct`'s original collection.
The problem seem to be with `Struct#to_a` and `Struct#select` methods from `struct.c` file that are defined unnecessarily.
### Proposed solution
The attached solution simply deletes `Struct#select` and `Struct#to_a`. A couple tests are added to show everything still works as before.
Please let me know if I can provide any more info and I'll be ready to do so.
---Files--------------------------------
struct_enumerable_fix.patch (2.8 KB)
struct_enumerable_fix2.patch (1.51 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>