You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"Nesting of either blocks is not allowed as it's error prone, due to type inference. Consider extracting the nested either block to a separate function."
42
55
) nn: NotNested
43
-
):Either[E, A] = boundary(Right(body))
56
+
):Either[E, A] =
57
+
givenForked=ForkedEvidence// just to satisfy the context function
58
+
givenSupervised=SupervisedEvidence
59
+
boundary(Right(body))
44
60
45
61
extension [E, A](inlinet: Either[E, A])
46
-
/** Unwrap the value of the `Either`, short-circuiting the computation to the enclosing [[either]], in case this is a left-value. */
62
+
/** Unwrap the value of the `Either`, short-circuiting the computation to the enclosing [[either]], in case this is a left-value. Can't
63
+
* be used in forked blocks without an either block in fork to prevent escaped Breaks that crash forked threads.
"The enclosing `either` call uses a different error type.\nIf it's explicitly typed, is the error type correct?\nNote that for options, the error type must contain a `Unit`."
69
-
)
70
-
case _ => error("`.ok()` can only be used within an `either` call.\nIs it present?")
71
-
}
86
+
inlineif availableInScope[Forked] &&!availableInScope[Supervised] then
87
+
error(
88
+
"This use of .ok() belongs to either block outside of the fork and is therefore illegal. Use either block inside of the forked block."
"The enclosing `either` call uses a different error type.\nIf it's explicitly typed, is the error type correct?\nNote that for options, the error type must contain a `Unit`."
99
+
)
100
+
case _ => error("`.ok()` can only be used within an `either` call.\nIs it present?")
101
+
}
72
102
73
103
extension [E, A](inlinef: Fork[Either[E, A]])
74
104
/** Join the fork and unwrap the value of its `Either` result, short-circuiting the computation to the enclosing [[either]], in case
@@ -80,12 +110,20 @@ object either:
80
110
transparentinlinedefok():A= f.join().ok()
81
111
82
112
extension [E](e: E)
113
+
/** Fail the computation by short-circuiting the enclosing [[either]] block with en error of type `E`. Can't be used in forked blocks
114
+
* without an either block in fork to prevent escaped Breaks that crash forked threads.
0 commit comments