@@ -172,7 +172,7 @@ impl AsyncGenerator {
172172 || state ==AsyncGeneratorState :: SuspendedYield
173173{
174174// a. Perform AsyncGeneratorResume(generator, completion).
175- Self :: resume ( & generator, completion, context) ;
175+ Self :: resume ( & generator, completion, context) ? ;
176176}
177177
178178// 11. Return promiseCapability.[[Promise]].
@@ -231,12 +231,12 @@ impl AsyncGenerator {
231231 generator. borrow_mut ( ) . data_mut ( ) . state =AsyncGeneratorState :: DrainingQueue ;
232232
233233// b. Perform ! AsyncGeneratorAwaitReturn(generator).
234- Self :: await_return ( & generator, return_value, context) ;
234+ Self :: await_return ( & generator, return_value, context) ? ;
235235}
236236// 9. Else if state is suspended-yield, then
237237else if state ==AsyncGeneratorState :: SuspendedYield {
238238// a. Perform AsyncGeneratorResume(generator, completion).
239- Self :: resume ( & generator, completion, context) ;
239+ Self :: resume ( & generator, completion, context) ? ;
240240}
241241// 10. Else,
242242// a. Assert: state is either executing or draining-queue.
@@ -323,7 +323,7 @@ impl AsyncGenerator {
323323// 10. If state is suspended-yield, then
324324if state ==AsyncGeneratorState :: SuspendedYield {
325325// a. Perform AsyncGeneratorResume(generator, completion).
326- Self :: resume ( & generator, completion, context) ;
326+ Self :: resume ( & generator, completion, context) ? ;
327327}
328328
329329// 11. Else,
@@ -371,7 +371,7 @@ impl AsyncGenerator {
371371done : bool ,
372372realm : Option < Realm > ,
373373context : & mut Context ,
374- ) {
374+ ) -> JsResult < ( ) > {
375375// 1. Assert: generator.[[AsyncGeneratorQueue]] is not empty.
376376// 2. Let next be the first element of generator.[[AsyncGeneratorQueue]].
377377// 3. Remove the first element from generator.[[AsyncGeneratorQueue]].
@@ -392,7 +392,7 @@ impl AsyncGenerator {
392392// a. Perform ! Call(promiseCapability.[[Reject]], undefined, « value »).
393393 promise_capability
394394. reject ( )
395- . call ( & JsValue :: undefined ( ) , & [ e. to_opaque ( context) ] , context)
395+ . call ( & JsValue :: undefined ( ) , & [ e. into_opaque ( context) ? ] , context)
396396. expect ( "cannot fail per spec" ) ;
397397}
398398
@@ -426,6 +426,7 @@ impl AsyncGenerator {
426426}
427427}
428428// 8. Return unused.
429+ Ok ( ( ) )
429430}
430431
431432/// `AsyncGeneratorResume ( generator, completion )`
@@ -442,7 +443,7 @@ impl AsyncGenerator {
442443generator : & JsObject < AsyncGenerator > ,
443444completion : CompletionRecord ,
444445context : & mut Context ,
445- ) {
446+ ) -> JsResult < ( ) > {
446447// 1. Assert: generator.[[AsyncGeneratorState]] is either suspended-start or suspended-yield.
447448assert ! ( matches!(
448449 generator. borrow( ) . data( ) . state,
@@ -463,7 +464,7 @@ impl AsyncGenerator {
463464let ( value, resume_kind) =match completion{
464465CompletionRecord :: Normal ( val) =>( val, GeneratorResumeKind :: Normal ) ,
465466CompletionRecord :: Return ( val) =>( val, GeneratorResumeKind :: Return ) ,
466- CompletionRecord :: Throw ( err) =>( err. to_opaque ( context) , GeneratorResumeKind :: Throw ) ,
467+ CompletionRecord :: Throw ( err) =>( err. into_opaque ( context) ? , GeneratorResumeKind :: Throw ) ,
467468} ;
468469
469470// 3. Let callerContext be the running execution context.
@@ -480,6 +481,7 @@ impl AsyncGenerator {
480481// 9. Assert: When we return here, genContext has already been removed from the execution context stack and
481482// callerContext is the currently running execution context.
482483// 10. Return unused.
484+ Ok ( ( ) )
483485}
484486
485487/// `AsyncGeneratorAwaitReturn ( generator )`
@@ -496,7 +498,7 @@ impl AsyncGenerator {
496498generator : & JsObject < AsyncGenerator > ,
497499value : JsValue ,
498500context : & mut Context ,
499- ) {
501+ ) -> JsResult < ( ) > {
500502// 1. Assert: generator.[[AsyncGeneratorState]] is draining-queue.
501503assert_eq ! (
502504 generator. borrow( ) . data( ) . state,
@@ -523,11 +525,11 @@ impl AsyncGenerator {
523525// 8. If promiseCompletion is an abrupt completion, then
524526Err ( e) =>{
525527// a. Perform AsyncGeneratorCompleteStep(generator, promiseCompletion, true).
526- Self :: complete_step ( generator, Err ( e) , true , None , context) ;
528+ Self :: complete_step ( generator, Err ( e) , true , None , context) ? ;
527529// b. Perform AsyncGeneratorDrainQueue(generator).
528- Self :: drain_queue ( generator, context) ;
530+ Self :: drain_queue ( generator, context) ? ;
529531// c. Return unused.
530- return ;
532+ return Ok ( ( ) ) ;
531533}
532534} ;
533535
@@ -549,10 +551,10 @@ impl AsyncGenerator {
549551let result =Ok ( args. get_or_undefined ( 0 ) . clone ( ) ) ;
550552
551553// c. Perform AsyncGeneratorCompleteStep(generator, result, true).
552- Self :: complete_step ( generator, result, true , None , context) ;
554+ Self :: complete_step ( generator, result, true , None , context) ? ;
553555
554556// d. Perform AsyncGeneratorDrainQueue(generator).
555- Self :: drain_queue ( generator, context) ;
557+ Self :: drain_queue ( generator, context) ? ;
556558
557559// e. Return undefined.
558560Ok ( JsValue :: undefined ( ) )
@@ -580,10 +582,10 @@ impl AsyncGenerator {
580582let result =Err ( JsError :: from_opaque ( args. get_or_undefined ( 0 ) . clone ( ) ) ) ;
581583
582584// c. Perform AsyncGeneratorCompleteStep(generator, result, true).
583- Self :: complete_step ( generator, result, true , None , context) ;
585+ Self :: complete_step ( generator, result, true , None , context) ? ;
584586
585587// d. Perform AsyncGeneratorDrainQueue(generator).
586- Self :: drain_queue ( generator, context) ;
588+ Self :: drain_queue ( generator, context) ? ;
587589
588590// e. Return undefined.
589591Ok ( JsValue :: undefined ( ) )
@@ -596,14 +598,16 @@ impl AsyncGenerator {
596598. build ( ) ;
597599
598600// 15. Perform PerformPromiseThen(promise, onFulfilled, onRejected).
599- // 16. Return unused.
600601Promise :: perform_promise_then (
601602& promise,
602603Some ( on_fulfilled) ,
603604Some ( on_rejected) ,
604605None ,
605606 context,
606607) ;
608+
609+ // 16. Return unused.
610+ Ok ( ( ) )
607611}
608612
609613/// `AsyncGeneratorDrainQueue ( generator )`
@@ -616,7 +620,10 @@ impl AsyncGenerator {
616620/// Panics if `generator` is not in the `DrainingQueue` state.
617621///
618622/// [spec]: https://tc39.es/ecma262/#sec-asyncgeneratordrainqueue
619- pub ( crate ) fn drain_queue ( generator : & JsObject < AsyncGenerator > , context : & mut Context ) {
623+ pub ( crate ) fn drain_queue (
624+ generator : & JsObject < AsyncGenerator > ,
625+ context : & mut Context ,
626+ ) ->JsResult < ( ) > {
620627// 1. Assert: generator.[[AsyncGeneratorState]] is draining-queue.
621628assert_eq ! (
622629 generator. borrow( ) . data( ) . state,
@@ -630,7 +637,7 @@ impl AsyncGenerator {
630637 generator. borrow_mut ( ) . data_mut ( ) . state =AsyncGeneratorState :: Completed ;
631638 generator. borrow_mut ( ) . data_mut ( ) . context =None ;
632639// b. Return unused.
633- return ;
640+ return Ok ( ( ) ) ;
634641}
635642
636643// 4. Let done be false.
@@ -651,7 +658,7 @@ impl AsyncGenerator {
651658// c. If completion is a return completion, then
652659CompletionRecord :: Return ( val) =>{
653660// i. Perform AsyncGeneratorAwaitReturn(generator).
654- Self :: await_return ( generator, val, context) ;
661+ Self :: await_return ( generator, val, context) ? ;
655662
656663// ii. Set done to true.
657664break ;
@@ -663,7 +670,7 @@ impl AsyncGenerator {
663670let completion = completion. consume ( ) . map ( |_|JsValue :: undefined ( ) ) ;
664671
665672// ii. Perform AsyncGeneratorCompleteStep(generator, completion, true).
666- Self :: complete_step ( generator, completion, true , None , context) ;
673+ Self :: complete_step ( generator, completion, true , None , context) ? ;
667674
668675// iii. If queue is empty, then
669676if generator. borrow ( ) . data ( ) . queue . is_empty ( ) {
@@ -678,5 +685,6 @@ impl AsyncGenerator {
678685}
679686
680687// 6. Return unused.
688+ Ok ( ( ) )
681689}
682690}