Skip to content

fix: IR lowering errors on program-level declarations that appear inside function scope #63

@refcell

Description

@refcell

In crates/ir/src/to_egglog/expr.rs, the lower_stmt catch-all returns Err(IrError::Unsupported(...)) for any unhandled statement type. Several program-level declaration variants -- ModuleDecl, ModuleImport, ContractDecl, ContractImpl, EventDecl, and ComptimeBranch -- are collected at the program level by lower_program but are not listed in the skip arm alongside TypeAssign, TraitDecl, ImplBlock, AbiDecl, and ComptimeFn, which are already silently skipped. If any of the missing variants appears in a scope that lower_stmt processes, the compiler produces a hard error with the entire AST node printed via Debug formatting.

These declarative statements should be added to the existing skip arm that returns an empty node, matching the handling already in place for TypeAssign and friends. This is a one-line fix: extend the existing pattern match to include the six missing variants.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions