Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/std/core/hnd.kk
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,16 @@ pub fun resume-shallow( r : resume-context<b,e,e0,r>, x : b ) : e0 r
cast-ev1(r.k)(Shallow(x))


pub fun finalize( r : resume-context<b,e,e0,r>, x : r ) : e r
//finalize(r.k,x)
(r.k)(Finalize(x))
// Applying the continuation with an immediate throw restores the handler which expects a return type `r`
// But because we are manually finalizing out of context, we are returning in a new context
// where only `()` makes sense, because we do not want to require a dummy value to finalize
extern unsafe-cast-unit-context(r: resume-context<b,e,e0,r>): resume-context<b,e,e0,()>
c inline "#1"
js inline "#1"

pub fun finalize( r : resume-context<b,e,e0,r> ) : e ()
// finalize(r.k,x)
(unsafe-cast-unit-context(r).k)(Finalize(()))

// -------------------------------------------
// Clauses
Expand Down