mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +00:00
revert accidental push to trunk
This commit is contained in:
parent
6d982001e8
commit
42932367e1
2 changed files with 2 additions and 55 deletions
|
@ -3,7 +3,7 @@ use bumpalo::Bump;
|
||||||
use operator::BinOp::Pizza;
|
use operator::BinOp::Pizza;
|
||||||
use operator::{BinOp, CalledVia};
|
use operator::{BinOp, CalledVia};
|
||||||
use parse::ast::Expr::{self, *};
|
use parse::ast::Expr::{self, *};
|
||||||
use parse::ast::{AssignedField, Def, Pattern};
|
use parse::ast::{AssignedField, Def};
|
||||||
use region::{Located, Region};
|
use region::{Located, Region};
|
||||||
use types;
|
use types;
|
||||||
|
|
||||||
|
@ -322,45 +322,7 @@ pub fn desugar<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a Loca
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
If((condition, then_branch, else_branch)) => {
|
other => panic!("TODO desugar {:?}", other),
|
||||||
// desugar if into case, meaning that
|
|
||||||
//
|
|
||||||
// if b then x else y
|
|
||||||
//
|
|
||||||
// becomes
|
|
||||||
//
|
|
||||||
// case b of
|
|
||||||
// False -> y
|
|
||||||
// _ -> x
|
|
||||||
let mut branches = Vec::with_capacity_in(2, arena);
|
|
||||||
|
|
||||||
// no type errors will occur here so using this region should be fine
|
|
||||||
let pattern_region = condition.region.clone();
|
|
||||||
|
|
||||||
branches.push(&*arena.alloc((
|
|
||||||
Located {
|
|
||||||
value: Pattern::Variant(&[], "False"),
|
|
||||||
region: pattern_region,
|
|
||||||
},
|
|
||||||
(*else_branch).clone(),
|
|
||||||
)));
|
|
||||||
|
|
||||||
branches.push(&*arena.alloc((
|
|
||||||
Located {
|
|
||||||
value: Pattern::Underscore,
|
|
||||||
region: pattern_region,
|
|
||||||
},
|
|
||||||
(*then_branch).clone(),
|
|
||||||
)));
|
|
||||||
|
|
||||||
desugar(
|
|
||||||
arena,
|
|
||||||
arena.alloc(Located {
|
|
||||||
value: Case(condition, branches),
|
|
||||||
region: loc_expr.region,
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -611,21 +611,6 @@ mod test_infer {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[test]
|
|
||||||
// fn if_with_int_literals() {
|
|
||||||
// infer_eq(
|
|
||||||
// indoc!(
|
|
||||||
// r#"
|
|
||||||
// if 1 == 1 then
|
|
||||||
// 42
|
|
||||||
// else
|
|
||||||
// 24
|
|
||||||
// "#
|
|
||||||
// ),
|
|
||||||
// "Int",
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn case_with_int_literals() {
|
fn case_with_int_literals() {
|
||||||
infer_eq(
|
infer_eq(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue