Skip to main content

Module lower

Module lower 

Source
Expand description

Semantic resolution and HIR lowering (#45).

Resolves the parsed CST into the opy-rs-owned Opy HIR contract (crate::hir::Program): declarations and references resolve to typed HIR nodes, custom enums fold to constants, vect becomes a vector, .format() becomes a format node, wait default arguments are filled, and subroutine calls become CallSubroutine statements. Semantic errors (unknown identifiers, unknown custom-enum members, invalid vect arity) are structured and source-located.

Builtin action/value/member identity, action/value position, signatures and arity, receiver categories, parameter enum-domain identities, and non-contextual source aliases resolve through the OPY semantic compatibility manifest (crate::manifest, issue #109) before Workshop emission: unknown or misplaced builtins fail here with structured, source-located diagnostics instead of surfacing as emitter catalog misses.

Ownership boundary: enum domains are catalog-identity links carried by the manifest signatures, but enum member lists are Workshop-owned catalog content. A member access on a declared domain identity resolves as an opaque Enum node and member-existence/domain checks (unknown-enum-member for Workshop enums, enum-domain-mismatch) are lowering-dependent (issue #8) — they are not approximated here. Custom (user-declared) enum member checks are OPY-level source semantics and stay in this frontend.

Functions§

lower
Lower a parsed program into the Opy HIR contract.
lower_with_preprocessing