mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-02 19:32:17 +00:00
Get rid of more type clones
This commit is contained in:
parent
7c3fe5bc44
commit
0b8ac07287
1 changed files with 24 additions and 20 deletions
|
@ -1000,11 +1000,11 @@ pub fn constrain_expr(
|
||||||
|
|
||||||
let closure_type = Type::Variable(*closure_var);
|
let closure_type = Type::Variable(*closure_var);
|
||||||
|
|
||||||
let function_type = Type::Function(
|
let function_type_index = constraints.push_type(Type::Function(
|
||||||
vec![record_type],
|
vec![record_type],
|
||||||
Box::new(closure_type),
|
Box::new(closure_type),
|
||||||
Box::new(field_type),
|
Box::new(field_type),
|
||||||
);
|
));
|
||||||
|
|
||||||
let cons = [
|
let cons = [
|
||||||
constraints.equal_types_var(
|
constraints.equal_types_var(
|
||||||
|
@ -1014,15 +1014,23 @@ pub fn constrain_expr(
|
||||||
region,
|
region,
|
||||||
),
|
),
|
||||||
{
|
{
|
||||||
let type_index = constraints.push_type(function_type.clone());
|
|
||||||
let expected_index = constraints.push_expected_type(expected);
|
let expected_index = constraints.push_expected_type(expected);
|
||||||
constraints.equal_types(type_index, expected_index, category.clone(), region)
|
constraints.equal_types(
|
||||||
|
function_type_index,
|
||||||
|
expected_index,
|
||||||
|
category.clone(),
|
||||||
|
region,
|
||||||
|
)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
let type_index = constraints.push_type(function_type);
|
let function_var_index =
|
||||||
let expected_index =
|
|
||||||
constraints.push_expected_type(NoExpectation(Variable(*function_var)));
|
constraints.push_expected_type(NoExpectation(Variable(*function_var)));
|
||||||
constraints.equal_types(type_index, expected_index, category, region)
|
constraints.equal_types(
|
||||||
|
function_type_index,
|
||||||
|
function_var_index,
|
||||||
|
category,
|
||||||
|
region,
|
||||||
|
)
|
||||||
},
|
},
|
||||||
record_con,
|
record_con,
|
||||||
];
|
];
|
||||||
|
@ -3499,11 +3507,11 @@ fn rec_defs_help(
|
||||||
&mut vars,
|
&mut vars,
|
||||||
);
|
);
|
||||||
|
|
||||||
let fn_type = Type::Function(
|
let fn_type_index = constraints.push_type(Type::Function(
|
||||||
pattern_types,
|
pattern_types,
|
||||||
Box::new(Type::Variable(closure_var)),
|
Box::new(Type::Variable(closure_var)),
|
||||||
Box::new(ret_type.clone()),
|
Box::new(ret_type.clone()),
|
||||||
);
|
));
|
||||||
let body_type = NoExpectation(ret_type.clone());
|
let body_type = NoExpectation(ret_type.clone());
|
||||||
let expr_con = constrain_expr(
|
let expr_con = constrain_expr(
|
||||||
constraints,
|
constraints,
|
||||||
|
@ -3518,6 +3526,7 @@ fn rec_defs_help(
|
||||||
|
|
||||||
let signature_index = constraints.push_type(signature);
|
let signature_index = constraints.push_type(signature);
|
||||||
let state_constraints = constraints.and_constraint(state.constraints);
|
let state_constraints = constraints.and_constraint(state.constraints);
|
||||||
|
let expected_index = constraints.push_expected_type(expected);
|
||||||
let cons = [
|
let cons = [
|
||||||
constraints.let_constraint(
|
constraints.let_constraint(
|
||||||
[],
|
[],
|
||||||
|
@ -3526,17 +3535,12 @@ fn rec_defs_help(
|
||||||
state_constraints,
|
state_constraints,
|
||||||
expr_con,
|
expr_con,
|
||||||
),
|
),
|
||||||
{
|
constraints.equal_types(
|
||||||
let fn_type_index = constraints.push_type(fn_type.clone());
|
fn_type_index,
|
||||||
let expected_index =
|
expected_index,
|
||||||
constraints.push_expected_type(expected.clone());
|
Category::Lambda,
|
||||||
constraints.equal_types(
|
region,
|
||||||
fn_type_index,
|
),
|
||||||
expected_index,
|
|
||||||
Category::Lambda,
|
|
||||||
region,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
// "fn_var is equal to the closure's type" - fn_var is used in code gen
|
// "fn_var is equal to the closure's type" - fn_var is used in code gen
|
||||||
// Store type into AST vars. We use Store so errors aren't reported twice
|
// Store type into AST vars. We use Store so errors aren't reported twice
|
||||||
constraints.store_index(
|
constraints.store_index(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue