Skip to content

Support cyclic imports and zero-forward-declaration semantics#25668

Closed
lbcheng888 wants to merge 1 commit intonim-lang:develfrom
lbcheng888:codex/default-user-reorder-orc-leaks
Closed

Support cyclic imports and zero-forward-declaration semantics#25668
lbcheng888 wants to merge 1 commit intonim-lang:develfrom
lbcheng888:codex/default-user-reorder-orc-leaks

Conversation

@lbcheng888
Copy link
Copy Markdown
Contributor

@lbcheng888 lbcheng888 commented Mar 27, 2026

Summary

  • support cyclic imports and zero-forward-declaration semantics in the compiler
  • make the user-module path work without manual forward declarations while keeping stdlib/system on the conservative path
  • async ORC leak fixes moved to stdlib: fix async ORC resource leaks #25683

Testing

Build a test compiler from compiler/nim.nim:

./bin/nim c --skipUserCfg --skipParentCfg -d:nimKochBootstrap -o:bin/nim_default_reorder compiler/nim.nim

Run the regression checks with that compiler:

./bin/nim_default_reorder c -r tests/modules/tcyclicimports_proc.nim
./bin/nim_default_reorder c -r tests/modules/tcyclicimports_types.nim
./bin/nim_default_reorder c -r tests/modules/tcyclicimports_noreorder.nim
./bin/nim_default_reorder c -r tests/misc/tnoforward.nim
./bin/nim_default_reorder c -d:testdef -r tests/modules/treorder.nim
./bin/nim_default_reorder c -r tests/pragmas/treorder.nim
./bin/nim_default_reorder c -r tests/overflow/toverflow_reorder.nim --overflowChecks:off
./bin/nim_default_reorder c tests/modules/tselfimport.nim

Collect module interfaces ahead of semchecking so cyclic imports can resolve exported symbols without hand-written forward declarations when code reordering is in effect.

Make code reordering the default path for non-stdlib, non-system modules so ordinary user code no longer needs manual forward declarations, keep stdlib/system on the conservative path, preserve explicit self-import errors, and update the regression tests for the default behavior.
@lbcheng888 lbcheng888 closed this Mar 27, 2026
@lbcheng888 lbcheng888 reopened this Mar 27, 2026
@Araq
Copy link
Copy Markdown
Member

Araq commented Mar 29, 2026

Make "fix ORC-related async resource leaks in asyncdispatch, the kqueue selector backend, and Windows AsyncEvent handling" its own PR.

@lbcheng888 lbcheng888 force-pushed the codex/default-user-reorder-orc-leaks branch from 7c8d2de to 27161c7 Compare March 29, 2026 22:42
@lbcheng888 lbcheng888 changed the title Support cyclic imports and zero-forward-declaration semantics; fix async ORC resource leaks Support cyclic imports and zero-forward-declaration semantics Mar 29, 2026
@lbcheng888 lbcheng888 closed this Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants