@@ -367,6 +367,7 @@ int repl(const vm::RuntimeConfig &config) {
367367 }
368368#endif
369369
370+ vm::MutableHandle<> resHandle{runtime.get ()};
370371 // SetUnbuffered because there is no explicit flush after prompt (>>).
371372 // There is also no explicitly flush at end of line. (An automatic flush
372373 // mechanism is not guaranteed to be present, from my experiment on Windows)
@@ -420,16 +421,18 @@ int repl(const vm::RuntimeConfig &config) {
420421 llvh::outs ().resetColor ();
421422 code.clear ();
422423 threwException = true ;
424+ } else {
425+ resHandle = std::move (*callRes);
423426 }
424427
425428 if (!ctx.jobsEmpty ()) {
426429 // Run the jobs until there are no more.
427430 vm::MutableHandle<vm::Callable> job{runtime.get ()};
428431 while (auto optJob = ctx.dequeueJob ()) {
429432 job = std::move (*optJob);
430- auto callRes = vm::Callable::executeCall0 (
433+ auto jobCallRes = vm::Callable::executeCall0 (
431434 job, runtime.get (), vm::Runtime::getUndefinedValue (), false );
432- if (LLVM_UNLIKELY (callRes == vm::ExecutionStatus::EXCEPTION )) {
435+ if (LLVM_UNLIKELY (jobCallRes == vm::ExecutionStatus::EXCEPTION )) {
433436 threwException = true ;
434437 runtime->printException (
435438 hasColors
@@ -446,7 +449,7 @@ int repl(const vm::RuntimeConfig &config) {
446449 continue ;
447450 }
448451
449- if ((*callRes) ->isUndefined ()) {
452+ if (resHandle ->isUndefined ()) {
450453 code.clear ();
451454 continue ;
452455 }
@@ -456,9 +459,7 @@ int repl(const vm::RuntimeConfig &config) {
456459 vm::operator <<(
457460 llvh::outs (),
458461 vm::StringPrimitive::createStringView (
459- runtime.get (),
460- vm::Handle<vm::StringPrimitive>::vmcast (
461- runtime->makeHandle (std::move (*callRes))))
462+ runtime.get (), vm::Handle<vm::StringPrimitive>::vmcast (resHandle))
462463 .getUTF16Ref (tmp))
463464 << " \n " ;
464465 code.clear ();
0 commit comments