toasty_core/stmt/
expr_let.rs

1use super::Expr;
2
3/// A scoped binding expression with one or more bindings.
4///
5/// Evaluates each binding in order, pushes all results into a new scope, then
6/// evaluates `body` in that scope. The body references binding `i` via
7/// `Arg(position=i, nesting=0)`.
8///
9/// `ExprLet` is transient scaffolding used during lowering. It is always
10/// inlined away (by substituting the bindings into the body) before the
11/// planner sees the expression tree.
12#[derive(Debug, Clone, PartialEq)]
13pub struct ExprLet {
14    /// Expressions whose results are bound as `arg(0)`, `arg(1)`, etc. in a
15    /// new scope.
16    pub bindings: Vec<Expr>,
17
18    /// The body expression evaluated in the new scope.
19    pub body: Box<Expr>,
20}
21
22impl From<ExprLet> for Expr {
23    fn from(value: ExprLet) -> Self {
24        Self::Let(value)
25    }
26}