pub fn block_uses_emit(b: &Block, callees: &HashMap<ExprId, Callee>) -> boolExpand description
Events track, slice 0 (spine #936): does this block contain a real
Events.emit[...] call anywhere — including nested branches, match arms,
lambdas, and any other expression position (a Paren, an Ok/Err
wrapper, a Call/RecordConstruction argument, a BinOp operand, …)?
Gates release-at-commit buffer threading (deps.__events) so a handler
that never emits keeps byte-identical output, mirroring block_uses_send’s
gate on deps.__exec.
Driven off the exhaustive walk_block_exprs/walk_exprs visitor rather
than a hand-rolled ExprKind match — a bespoke match here previously
covered only MethodCall/Block/If/Match/Lambda and silently
disagreed with lower_expr_into (which recurses into every expression
position), so do (Events.emit[E](event)) — one added paren — compiled
clean but emitted a body that referenced an undeclared __events local
(tsc-only failure, no bynk diagnostic). Riding the walker means this
can’t drift from the lowering again: a new ExprKind variant fails to
compile here until walk_exprs itself is taught to visit it.
#1187’s slice 6 plumbing (review of #1202): reads the checker’s own
already-resolved Callee::Capability{cap:"Events",op:"emit"} for each
visited call site instead of a bare-Ident("Events")-receiver name
match. Was deliberately syntactic before this — this function’s own
prior doc comment named the locally-shadowed-Events false positive an
“accepted approximation,” matching block_uses_send’s own precedent —
but that approximation stopped being harmless once crate::project:: unit_table_uses_emit (the project-wide compose-gating twin this
function’s own callers must agree with) became precise first: the two
disagreeing on exactly the shadowed case produces a real tsc type
error (a deps.__eventsDispatch call site with nothing supplying it),
not just an unused interface field. block_uses_send needs no matching
fix — a ~> send is a real Statement::Send AST variant, not a method
call that could be shadowed, so it was never approximate to begin with.