add comment

This commit is contained in:
Folkert 2022-07-10 20:48:57 +02:00
parent ff2b5cf6f0
commit 830dd03b30
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
2 changed files with 22 additions and 2 deletions

View file

@ -2394,7 +2394,27 @@ fn get_lookup_symbols(expr: &Expr, var_store: &mut VarStore) -> Vec<(Symbol, Var
symbols
}
pub fn convert_toplevel_expect(mut loc_expr: Loc<Expr>) -> Loc<Expr> {
/// Here we transform
///
/// > expect
/// > a = 1
/// > b = 2
/// >
/// > a == b
///
/// into
///
/// > a = 1
/// > b = 2
/// >
/// > expect a == b
/// >
/// > emptyrecord
///
/// This is supposed to happen just before monomorphization:
/// all type errors and such are generated from the user source,
/// but this transformation means that we don't need special codegen for toplevel expects
pub fn toplevel_expect_to_inline_expect(mut loc_expr: Loc<Expr>) -> Loc<Expr> {
enum StoredDef {
NonRecursive(Region, Box<Def>),
Recursive(Region, Vec<Def>, IllegalCycleMark),

View file

@ -4817,7 +4817,7 @@ fn build_pending_specializations<'a>(
);
}
let body = roc_can::expr::convert_toplevel_expect(body);
let body = roc_can::expr::toplevel_expect_to_inline_expect(body);
let proc = PartialProc {
annotation: expr_var,