Skip to main content

Module statements

Module statements 

Source
Expand description

Statement resolution - transforms declarations and control flow into slot-indexed variants and resolves import statements at compile time.

Key behaviors:

  • Variable/constant/array declarations: resolve the initializer expression first, then declare the name so the initializer cannot reference itself
  • Function declarations: declare the name in the outer scope first (enabling recursion), then push a new scope for parameters and resolve the body
  • ForEach/ForRange: the loop variable is declared inside its own scope so it does not leak into the surrounding scope after the loop ends
  • ImportFile / ImportFileNamed: reads the file from disk, lexes, parses, and resolves it inline - the result replaces the import statement with ResolvedImportFile { body } containing the fully resolved statements. ImportFileNamed additionally filters to only the requested names before resolving. Both silently return the original unresolved statement on any IO/parse failure