Skip to main content

lower_fn_body_ir

Function lower_fn_body_ir 

Source
pub fn lower_fn_body_ir(f: &FnDecl, program: &CheckedProgram) -> IrExpr
Expand description

Lower a function/method body: seeds scope from f’s params (and its own rigid type variables — its own [T, ...] type parameters, plus a generic receiver’s, for a method), lowers the body as an ordinary value block, then wraps the tail via wrap_body_return. Distinct from lower_block_ir, which lowers a nested block as a bare value with no such wrapping.

Handler bodies are out of scope for this entry point: a handler’s own non-local bare-ident forms (store-field/cell reads, agent self, the actor binder, transition old/new) need resolved-identity plumbing (store_fields, agent_state_ty, actor_binding — the Ctx fields check_handler_body seeds, checker.rs:930-960) this entry point has no parameter for and does not commission (P6.1’s own Decision C) — calling this on a handler body would silently misclassify any bare ident matching one of those forms as a Local/Global miss (todo!()) rather than the specific kind it actually is. lower_handler_body_ir (P6.9, #1167) is that dedicated entry point, finally closing this gap — it is not built by widening this function, since a free fn/method and an agent handler seed genuinely different scopes (rigid type variables here, agent self/store cells there) that would otherwise have to coexist behind one signature for no shared benefit. lower_service_handler_body_ir (P6.11, #1171) is the third sibling on the same rule, not a second widening — a service handler’s own scope (params/binder only) is disjoint from both of the other two.