diff --git a/src/checker.cpp b/src/checker.cpp index 0d82ec9f9..340b74241 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -6027,8 +6027,8 @@ gb_internal void check_import_entities(Checker *c) { } TIME_SECTION("check_import_entities - check delayed entities"); - for_array(i, package_order) { - ImportGraphNode *node = package_order[i]; + for (isize pkg_index = 0; pkg_index < package_order.count; pkg_index++) { + ImportGraphNode *node = package_order[pkg_index]; GB_ASSERT(node->scope->flags&ScopeFlag_Pkg); AstPackage *pkg = node->scope->pkg; @@ -6054,9 +6054,20 @@ gb_internal void check_import_entities(Checker *c) { reset_checker_context(&ctx, f, &untyped); ctx.collect_delayed_decls = true; + + bool will_recheck_foreign_block = false; for (Ast *decl : f->delayed_decls_queues[AstDelayQueue_ForeignBlock]) { - check_add_foreign_block_decl(&ctx, decl); + if (check_add_foreign_block_decl(&ctx, decl)) { + pkg_index -= 1; // Re-check package + will_recheck_foreign_block = true; + break; + } } + + if (will_recheck_foreign_block) { + break; + } + array_clear(&f->delayed_decls_queues[AstDelayQueue_ForeignBlock]); } diff --git a/tests/issues/run.bat b/tests/issues/run.bat index 2f42e3e21..0b92f07ff 100644 --- a/tests/issues/run.bat +++ b/tests/issues/run.bat @@ -35,6 +35,7 @@ set COMMON=-define:ODIN_TEST_FANCY=false -file -vet -strict-style -ignore-unused ..\..\..\odin test ..\test_pr_6470.odin %COMMON% || exit /b ..\..\..\odin test ..\test_pr_6470.odin -define:TEST_EXPECT_FAILURE=true %COMMON% 2>&1 | find /c "Error:" | findstr /x "1" || exit /b ..\..\..\odin test ..\test_pr_6476.odin %COMMON% || exit /b +..\..\..\odin check ..\test_issue_6484.odin -no-entry-point %COMMON% || exit /b @echo off diff --git a/tests/issues/run.sh b/tests/issues/run.sh index 8a7800cd7..17b1b75e0 100755 --- a/tests/issues/run.sh +++ b/tests/issues/run.sh @@ -58,6 +58,8 @@ else echo "SUCCESSFUL 0/1" exit 1 fi +$ODIN check ../test_issue_6484.odin -no-entry-point $COMMON + set +x popd diff --git a/tests/issues/test_issue_6484.odin b/tests/issues/test_issue_6484.odin new file mode 100644 index 000000000..d115a12ef --- /dev/null +++ b/tests/issues/test_issue_6484.odin @@ -0,0 +1,17 @@ +// Tests issue #6484 https://github.com/odin-lang/Odin/pull/6484 +package test_issues + +foreign import lib "this_library_does_not_exist" + +foreign lib { + foo :: proc(int) --- + when true {} + when true {} + bar :: proc() --- +} + +foo_bar :: proc { + foo, + bar, +} +