mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
Merge branch 'def-types-tweaks' into builtins-in-roc
This commit is contained in:
commit
6009768991
3 changed files with 44 additions and 49 deletions
|
@ -100,7 +100,6 @@ pub fn constrain_expr(
|
|||
if fields.is_empty() {
|
||||
constrain_empty_record(constraints, region, expected)
|
||||
} else {
|
||||
let mut field_exprs = SendMap::default();
|
||||
let mut field_types = SendMap::default();
|
||||
let mut field_vars = Vec::with_capacity(fields.len());
|
||||
|
||||
|
@ -115,7 +114,6 @@ pub fn constrain_expr(
|
|||
constrain_field(constraints, env, field_var, &*loc_field_expr);
|
||||
|
||||
field_vars.push(field_var);
|
||||
field_exprs.insert(label.clone(), loc_field_expr);
|
||||
field_types.insert(label.clone(), RecordField::Required(field_type));
|
||||
|
||||
rec_constraints.push(field_con);
|
||||
|
@ -1194,13 +1192,7 @@ fn constrain_when_branch(
|
|||
|
||||
// must introduce the headers from the pattern before constraining the guard
|
||||
let state_constraints = constraints.and_constraint(state.constraints);
|
||||
let inner = constraints.let_constraint(
|
||||
[],
|
||||
[],
|
||||
SendMap::default(),
|
||||
guard_constraint,
|
||||
ret_constraint,
|
||||
);
|
||||
let inner = constraints.let_constraint([], [], [], guard_constraint, ret_constraint);
|
||||
|
||||
constraints.let_constraint([], state.vars, state.headers, state_constraints, inner)
|
||||
} else {
|
||||
|
@ -1546,13 +1538,7 @@ fn constrain_def(
|
|||
);
|
||||
|
||||
let cons = [
|
||||
constraints.let_constraint(
|
||||
[],
|
||||
[],
|
||||
SendMap::default(),
|
||||
Constraint::True,
|
||||
ret_constraint,
|
||||
),
|
||||
constraints.let_constraint([], [], [], Constraint::True, ret_constraint),
|
||||
// Store type into AST vars. We use Store so errors aren't reported twice
|
||||
constraints.store(signature, expr_var, std::file!(), std::line!()),
|
||||
];
|
||||
|
@ -1605,7 +1591,7 @@ fn constrain_def_make_constraint(
|
|||
let def_con = constraints.let_constraint(
|
||||
[],
|
||||
new_infer_variables,
|
||||
SendMap::default(), // empty, because our functions have no arguments!
|
||||
[], // empty, because our functions have no arguments!
|
||||
and_constraint,
|
||||
expr_con,
|
||||
);
|
||||
|
@ -1721,6 +1707,11 @@ fn instantiate_rigids(
|
|||
annotation.substitute(&rigid_substitution);
|
||||
}
|
||||
|
||||
// TODO investigate when we can skip this. It seems to only be required for correctness
|
||||
// for recursive functions. For non-recursive functions the final type is correct, but
|
||||
// alias information is sometimes lost
|
||||
//
|
||||
// Skipping all of this cloning here would be neat!
|
||||
let loc_annotation_ref = Loc::at(loc_pattern.region, &annotation);
|
||||
if let Pattern::Identifier(symbol) = loc_pattern.value {
|
||||
headers.insert(symbol, Loc::at(loc_pattern.region, annotation.clone()));
|
||||
|
@ -1783,8 +1774,8 @@ pub fn rec_defs_help(
|
|||
// TODO investigate if this let can be safely removed
|
||||
let def_con = constraints.let_constraint(
|
||||
[],
|
||||
[], // empty because Roc function defs have no args
|
||||
SendMap::default(), // empty because Roc function defs have no args
|
||||
[], // empty because Roc function defs have no args
|
||||
[], // empty because Roc function defs have no args
|
||||
Constraint::True, // I think this is correct, once again because there are no args
|
||||
expr_con,
|
||||
);
|
||||
|
@ -1974,7 +1965,7 @@ pub fn rec_defs_help(
|
|||
rigid_info.constraints.push(constraints.let_constraint(
|
||||
new_rigid_variables,
|
||||
def_pattern_state.vars,
|
||||
SendMap::default(), // no headers introduced (at this level)
|
||||
[], // no headers introduced (at this level)
|
||||
def_con,
|
||||
Constraint::True,
|
||||
));
|
||||
|
@ -1995,7 +1986,7 @@ pub fn rec_defs_help(
|
|||
constraints.let_constraint(
|
||||
[],
|
||||
[],
|
||||
SendMap::default(),
|
||||
[],
|
||||
Constraint::True,
|
||||
ret_constraint,
|
||||
),
|
||||
|
@ -2009,7 +2000,7 @@ pub fn rec_defs_help(
|
|||
rigid_info.constraints.push(constraints.let_constraint(
|
||||
new_rigid_variables,
|
||||
def_pattern_state.vars,
|
||||
SendMap::default(), // no headers introduced (at this level)
|
||||
[], // no headers introduced (at this level)
|
||||
def_con,
|
||||
Constraint::True,
|
||||
));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue