Skip to content

Multi-module codegen via flattening (C7e)#111

Merged
aallan merged 1 commit into
mainfrom
fix/cross-module-codegen
Feb 27, 2026
Merged

Multi-module codegen via flattening (C7e)#111
aallan merged 1 commit into
mainfrom
fix/cross-module-codegen

Conversation

@aallan

@aallan aallan commented Feb 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • Imported function bodies are compiled into the same WASM module via flattening (no WASM linking needed)
  • ModuleCall nodes desugared to flat FnCall in wasm.py since imported functions exist locally
  • Private helpers called by imported public functions are compiled automatically
  • Guard rail updated: only truly undefined functions error; imported functions pass through
  • vera compile and vera run now work with multi-module programs
  • modules.vera example compiles and runs end-to-end

Test plan

  • 951 tests pass (943 + 8 new cross-module codegen tests)
  • mypy clean
  • All 14 examples pass vera check and vera verify
  • All validation scripts pass (README, spec, version sync)
  • vera compile examples/modules.vera produces valid WASM
  • vera run examples/modules.vera --fn abs_max -- -3 -5 returns 3
  • vera run examples/modules.vera --fn clamp -- 10 1 5 returns 5

Closes #50
Closes part of #14

🤖 Generated with Claude Code

Imported function bodies are compiled into the same WASM module as the
importing program. ModuleCall nodes are desugared to flat FnCall in
wasm.py since the imported function exists in the local module. Private
helpers called by imported public functions are compiled automatically.

Closes #50

Co-Authored-By: Claude <noreply@anthropic.invalid>
@aallan aallan merged commit 079227f into main Feb 27, 2026
10 checks passed
@aallan aallan deleted the fix/cross-module-codegen branch February 27, 2026 16:51
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.

Module-level code generation

1 participant