fix: let
This commit is contained in:
@@ -194,11 +194,18 @@ impl<Ctx: CodegenContext> Compile<Ctx> for Let {
|
||||
for &expr in scc_exprs {
|
||||
let ir = ctx.get_ir(expr);
|
||||
let value = if let Ir::Thunk(inner) = ir {
|
||||
ctx.get_ir(*inner).compile(ctx)
|
||||
let inner_ir = ctx.get_ir(*inner);
|
||||
// Don't unwrap Thunk if inner is a Let expression
|
||||
// to avoid generating IIFE that executes immediately
|
||||
if matches!(inner_ir, Ir::Let(_)) {
|
||||
ir.compile(ctx)
|
||||
} else {
|
||||
inner_ir.compile(ctx)
|
||||
}
|
||||
} else {
|
||||
ir.compile(ctx)
|
||||
};
|
||||
js_statements.push(format!("let expr{}={}", expr.0, value));
|
||||
js_statements.push(format!("const expr{}={}", expr.0, value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user