mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
constrain expect
This commit is contained in:
parent
ed7906ccbb
commit
4dd0ee6543
1 changed files with 30 additions and 0 deletions
|
@ -406,6 +406,36 @@ pub fn constrain_expr(
|
|||
)
|
||||
}
|
||||
|
||||
Expect(loc_cond, continuation) => {
|
||||
let expect_bool = |region| {
|
||||
let bool_type = Type::Variable(Variable::BOOL);
|
||||
Expected::ForReason(Reason::IfCondition, bool_type, region)
|
||||
};
|
||||
|
||||
let cond_con = constrain_expr(
|
||||
env,
|
||||
loc_cond.region,
|
||||
&loc_cond.value,
|
||||
expect_bool(loc_cond.region),
|
||||
);
|
||||
|
||||
let continuation_con = constrain_expr(
|
||||
env,
|
||||
continuation.region,
|
||||
&continuation.value,
|
||||
ForReason(
|
||||
Reason::IfBranch {
|
||||
index: Index::zero_based(0),
|
||||
total_branches: 0,
|
||||
},
|
||||
expected.get_type(),
|
||||
continuation.region,
|
||||
),
|
||||
);
|
||||
|
||||
exists(vec![], And(vec![cond_con, continuation_con]))
|
||||
}
|
||||
|
||||
If {
|
||||
cond_var,
|
||||
branch_var,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue