mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
Fix constraining
This commit is contained in:
parent
e2b30e5301
commit
25693f8ffe
1 changed files with 15 additions and 5 deletions
|
@ -483,12 +483,22 @@ pub fn constrain_expr(
|
|||
constraints.exists(vars, and_constraint)
|
||||
}
|
||||
Expr::Crash { msg, ret_var } => {
|
||||
let expected_msg = Expected::ForReason(Reason::CrashArg, str_type(), msg.region);
|
||||
let expected_ret = constraints.push_expected_type(expected);
|
||||
let str_index = constraints.push_type(types, Types::STR);
|
||||
let expected_msg = constraints.push_expected_type(Expected::ForReason(
|
||||
Reason::CrashArg,
|
||||
str_index,
|
||||
msg.region,
|
||||
));
|
||||
|
||||
let msg_is_str = constrain_expr(constraints, env, msg.region, &msg.value, expected_msg);
|
||||
let magic =
|
||||
constraints.equal_types_var(*ret_var, expected_ret, Category::Crash, region);
|
||||
let msg_is_str = constrain_expr(
|
||||
types,
|
||||
constraints,
|
||||
env,
|
||||
msg.region,
|
||||
&msg.value,
|
||||
expected_msg,
|
||||
);
|
||||
let magic = constraints.equal_types_var(*ret_var, expected, Category::Crash, region);
|
||||
|
||||
let and = constraints.and_constraint([msg_is_str, magic]);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue