mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
implement basic type error reporting
This commit is contained in:
parent
4dd0ee6543
commit
903583f1d4
5 changed files with 74 additions and 14 deletions
|
|
@ -409,7 +409,7 @@ 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)
|
||||
Expected::ForReason(Reason::ExpectCondition, bool_type, region)
|
||||
};
|
||||
|
||||
let cond_con = constrain_expr(
|
||||
|
|
@ -419,19 +419,8 @@ pub fn constrain_expr(
|
|||
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,
|
||||
),
|
||||
);
|
||||
let continuation_con =
|
||||
constrain_expr(env, continuation.region, &continuation.value, expected);
|
||||
|
||||
exists(vec![], And(vec![cond_con, continuation_con]))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue