Skip to content

Commit

Permalink
Remove modules from import table if they raised exceptions on import
Browse files Browse the repository at this point in the history
  • Loading branch information
klange committed Dec 21, 2023
1 parent fe430bb commit 2685f49
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1317,11 +1317,12 @@ int krk_loadModule(KrkString * path, KrkValue * moduleOut, KrkString * runAs, Kr
krk_runfile(fileName,fileName);
*moduleOut = OBJECT_VAL(krk_currentThread.module);
krk_currentThread.module = enclosing;
if (!IS_OBJECT(*moduleOut)) {
if (!IS_OBJECT(*moduleOut) || (krk_currentThread.flags & KRK_THREAD_HAS_EXCEPTION)) {
if (!(krk_currentThread.flags & KRK_THREAD_HAS_EXCEPTION)) {
krk_runtimeError(vm.exceptions->importError,
"Failed to load module '%S' from '%s'", runAs, fileName);
}
krk_tableDelete(&vm.modules, OBJECT_VAL(runAs));
return 0;
}

Expand Down

0 comments on commit 2685f49

Please sign in to comment.