@@ -483,7 +483,7 @@ inline bool invoke_function(const FuncType& func_type, uint32_t func_idx, Instan
483483
484484 const auto ret = execute_internal (instance, func_idx, stack.rend (), depth + 1 );
485485 // Bubble up traps
486- if (ret. trapped )
486+ if (ret == nullptr )
487487 return false ;
488488
489489 stack.drop (num_args - num_outputs);
@@ -492,13 +492,13 @@ inline bool invoke_function(const FuncType& func_type, uint32_t func_idx, Instan
492492
493493} // namespace
494494
495- ExecutionResult execute_internal (Instance& instance, FuncIdx func_idx, Value* args_end, int depth)
495+ Value* execute_internal (Instance& instance, FuncIdx func_idx, Value* args_end, int depth)
496496{
497497 assert (args_end != nullptr );
498498
499499 assert (depth >= 0 );
500500 if (depth > CallStackLimit)
501- return Trap ;
501+ return nullptr ;
502502
503503 const auto & func_type = instance.module ->get_function_type (func_idx);
504504
@@ -508,9 +508,12 @@ ExecutionResult execute_internal(Instance& instance, FuncIdx func_idx, Value* ar
508508 if (func_idx < instance.imported_functions .size ())
509509 {
510510 const auto res = instance.imported_functions [func_idx].function (instance, args, depth);
511+ if (res.trapped )
512+ return nullptr ;
513+
511514 if (res.has_value )
512515 args[0 ] = res.value ;
513- return res ;
516+ return args ;
514517 }
515518
516519 const auto & code = instance.module ->get_code (func_idx);
@@ -1538,9 +1541,9 @@ ExecutionResult execute_internal(Instance& instance, FuncIdx func_idx, Value* ar
15381541 if (stack.size () != 0 && args != nullptr )
15391542 args[0 ] = stack.top ();
15401543
1541- return Void ;
1544+ return args ;
15421545
15431546trap:
1544- return Trap ;
1547+ return nullptr ;
15451548}
15461549} // namespace fizzy
0 commit comments