[#106341] [Ruby master Bug#18369] users.detect(:name, "Dorian") as shorthand for users.detect { |user| user.name == "Dorian" } — dorianmariefr <noreply@...>
Issue #18369 has been reported by dorianmariefr (Dorian Mari辿).
14 messages
2021/11/30
[#106351] [Ruby master Bug#18371] Release branches (release information in general) — "tenderlovemaking (Aaron Patterson)" <noreply@...>
Issue #18371 has been reported by tenderlovemaking (Aaron Patterson).
7 messages
2021/11/30
[ruby-core:105880] [Ruby master Bug#18243] Ractor.make_shareable does not freeze the receiver of a Proc but allows accessing ivars of it
From:
"Dan0042 (Daniel DeLorme)" <noreply@...>
Date:
2021-11-01 02:14:45 UTC
List:
ruby-core #105880
Issue #18243 has been updated by Dan0042 (Daniel DeLorme).
It's not uncommon for a proc to have behavior that is independent of `self`. Let's say:
Ractor.make_shareable(-> x { x + 1 })
In this case it's irrelevant if `self` is shareable or not, because it's never used in the proc. There's no method call or ivar access for `self`. It would be inconvenient if that kind of proc required `self` to be shareable. From the posts by @eregon it was unclear to me if "self must be shareable" was intended only for an explicit reference to `self`.
----------------------------------------
Bug #18243: Ractor.make_shareable does not freeze the receiver of a Proc but allows accessing ivars of it
https://bugs.ruby-lang.org/issues/18243#change-94422
* Author: Eregon (Benoit Daloze)
* Status: Open
* Priority: Normal
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
```ruby
class C
attr_accessor :foo
def setter_proc
Ractor.make_shareable(-> v { @foo = v })
end
end
c = C.new
c.foo = 1
p c
proc = c.setter_proc
p c.frozen?
Ractor.new(proc) { |s| s.call(42) }.take
p c
```
gives
```
#<C:0x00007f2a3aae7a98 @foo=1>
false
#<C:0x00007f2a3aae7a98 @foo=42> # BUG
```
But that must be a bug, it means the non-main Ractor can directly mutate an object from the main Ractor.
I found this while thinking about https://github.com/ruby/ostruct/pull/29/files and
whether `Ractor.make_shareable` would freeze `@table` and the `OpenStruct` instance (I think it needs to).
Repro code for ostruct and changing ostruct.rb to `$setter = ::Ractor.make_shareable(setter_proc)`:
```ruby
require 'ostruct'
os = OpenStruct.new
os.foo = 1
$setter.call(2)
p os
Ractor.new($setter) { |s| s.call(42) }.take
p os
```
gives
```
#<OpenStruct foo=2>
<internal:ractor>:267: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
#<OpenStruct foo=42> # BUG
```
--
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>