feat(modules): support local module imports and exports #59

Merged
rdenadai merged 3 commits from feat/modules-sep-013 into main 2026-10-03 21:01:18 +00:00
Owner

Summary

Sigil programs can now import local modules and share declarations across files, enabling codebases to organize reusable code without combining every source into one file.

The compiler builds a module graph, analyzes module declarations and exports, and compiles linked modules together. Imports support qualified paths, aliases, and selected members; diagnostics cover missing modules, unresolved symbols, and import conflicts.

Design decisions

  • Resolve module paths relative to the importing source file and reject ambiguous or cyclic dependency graphs.
  • Keep module namespaces explicit through qualified codegen names, preventing collisions between declarations in separate files.
  • Restrict exports to declared public members and validate imports during semantic analysis.
  • Add end-to-end coverage for native compilation, module regressions, and the documented example.

Tests

  • ruff format --check ./src
  • ruff check ./src ./tests
  • pytest tests -q -m "not e2e and not performance" (2150 passed, 1 skipped, 37 xfailed)
  • Focused module and class codegen tests (167 passed, 1 skipped)
## Summary Sigil programs can now import local modules and share declarations across files, enabling codebases to organize reusable code without combining every source into one file. The compiler builds a module graph, analyzes module declarations and exports, and compiles linked modules together. Imports support qualified paths, aliases, and selected members; diagnostics cover missing modules, unresolved symbols, and import conflicts. ## Design decisions - Resolve module paths relative to the importing source file and reject ambiguous or cyclic dependency graphs. - Keep module namespaces explicit through qualified codegen names, preventing collisions between declarations in separate files. - Restrict exports to declared public members and validate imports during semantic analysis. - Add end-to-end coverage for native compilation, module regressions, and the documented example. ## Tests - `ruff format --check ./src` - `ruff check ./src ./tests` - `pytest tests -q -m "not e2e and not performance"` (2150 passed, 1 skipped, 37 xfailed) - Focused module and class codegen tests (167 passed, 1 skipped)
feat(modules): add local module imports and exports
Some checks failed
Sigil / test (3.13) (pull_request) Failing after 7m59s
bcd962cb46
Enable projects to split code into local modules with explicit APIs,
dependency-ordered initialization, and native linking.
fix(modules): validate writes and top-level statements
Some checks failed
Sigil / test (3.13) (pull_request) Failing after 8m2s
b3bbbe9874
test(codegen): tolerate normalized LLVM signatures
All checks were successful
Sigil / test (3.13) (pull_request) Successful in 8m7s
770dc9e5e6
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rdenadai/sigil!59
No description provided.