diff options
author | Ben Gamari <ben@smart-cactus.org> | 2022-07-15 17:11:06 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-07-16 07:21:51 -0400 |
commit | 4beb9f3c367e1f7ee80b5458318d9f91622e4568 (patch) | |
tree | 9733fc2ed9895a6637a3650583b90dc5ae880841 /testsuite | |
parent | 89d169ec0c4e9c1e6cf4a6373a1992dad7474d55 (diff) | |
download | haskell-4beb9f3c367e1f7ee80b5458318d9f91622e4568.tar.gz |
Document RuntimeRep polymorphism limitations of catch#, et al
As noted in #21868, several primops accepting continuations producing
RuntimeRep-polymorphic results aren't nearly as polymorphic as their
types suggest. Document this limitation and adapt the `UnliftedWeakPtr`
test to avoid breaking this limitation in `keepAlive#`.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/primops/should_run/UnliftedWeakPtr.hs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/testsuite/tests/primops/should_run/UnliftedWeakPtr.hs b/testsuite/tests/primops/should_run/UnliftedWeakPtr.hs index d957485eba..f10d9a16d3 100644 --- a/testsuite/tests/primops/should_run/UnliftedWeakPtr.hs +++ b/testsuite/tests/primops/should_run/UnliftedWeakPtr.hs @@ -23,7 +23,7 @@ main = do case newMutVar# False s1 of (# s2, val_var #) -> case keepAlive# val_var s2 (inner mvar val_var) of - (# s3, wk, strs #) -> + (# s3, Res wk strs #) -> case unIO performGC s3 of (# s4, _ #) -> case deRefWeak# wk s4 of @@ -33,15 +33,19 @@ main = do (# s6, strs ++ [ show (I# j), r ] #) print res +data Res = Res (Weak# (MutableByteArray# RealWorld)) [String] + inner :: MVar# RealWorld String -> MutVar# RealWorld Bool -> State# RealWorld - -> (# State# RealWorld, Weak# U, [String] #) + -> (# State# RealWorld, Res #) inner mvar u s0 = - case mkWeak# u (U 42#) (finalise mvar) s0 of - (# s1, wk #) -> - case deRefWeak# wk s1 of - (# s2, i, U u #) -> (# s2, wk, [ show (I# i), show (I# u) ] #) + case newByteArray# 42# s0 of + (# s1, ba# #) -> + case mkWeak# u ba# (finalise mvar) s1 of + (# s2, wk #) -> + case deRefWeak# wk s2 of + (# s3, i, ba'# #) -> (# s3, Res wk [ show (I# i), show (I# (sizeofMutableByteArray# ba'#)) ] #) finalise :: MVar# RealWorld String -> State# RealWorld -> (# State# RealWorld, () #) finalise mvar s0 = |