Skip to content

Commit a38168b

Browse files
committed
Fix Ractor.store_if_absent
It in fact yields `nil`. Added `nil` in block parameter for testing.
1 parent 91578f0 commit a38168b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

core/ractor.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ class Ractor
603603
# }
604604
# }.map(&:value).uniq.size #=> 1 and f() is called only once
605605
#
606-
def self.store_if_absent: (Symbol) { () -> untyped } -> untyped
606+
def self.store_if_absent: [A] (Symbol) { (nil) -> A } -> A
607607

608608
# <!--
609609
# rdoc-file=ractor.rb

test/stdlib/Ractor_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ def test_shareable?
107107
Ractor, :shareable?, []
108108
end
109109

110+
def test_store_if_absent
111+
assert_send_type(
112+
"(Symbol) { (nil) -> true } -> true",
113+
Ractor, :store_if_absent, :test_store_if_absent, &->(_x) { true }
114+
)
115+
end
116+
110117
def test_yield
111118
Ractor.new(Ractor.current) { |r| loop { r.take } }
112119

0 commit comments

Comments
 (0)