mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
highlight code snippets better
This commit is contained in:
parent
c326b09964
commit
7632a4b484
11 changed files with 216 additions and 188 deletions
|
@ -149,8 +149,13 @@ pub fn constrain_expr(
|
|||
let mut vars = Vec::with_capacity(updates.len() + 2);
|
||||
let mut cons = Vec::with_capacity(updates.len() + 1);
|
||||
for (field_name, Field { var, loc_expr, .. }) in updates.clone() {
|
||||
let (var, tipe, con) =
|
||||
constrain_field_update(env, var, region, field_name.clone(), &loc_expr);
|
||||
let (var, tipe, con) = constrain_field_update(
|
||||
env,
|
||||
var,
|
||||
loc_expr.region,
|
||||
field_name.clone(),
|
||||
&loc_expr,
|
||||
);
|
||||
fields.insert(field_name, tipe);
|
||||
vars.push(var);
|
||||
cons.push(con);
|
||||
|
@ -498,6 +503,7 @@ pub fn constrain_expr(
|
|||
expr_var,
|
||||
loc_cond,
|
||||
branches,
|
||||
..
|
||||
} => {
|
||||
// Infer the condition expression's type.
|
||||
let cond_var = *cond_var;
|
||||
|
@ -935,16 +941,16 @@ fn constrain_def(env: &Env, def: &Def, body_con: Constraint) -> Constraint {
|
|||
let mut new_rigids = Vec::new();
|
||||
|
||||
let expr_con = match &def.annotation {
|
||||
Some((annotation, introduced_vars, ann_def_aliases)) => {
|
||||
def_aliases = ann_def_aliases.clone();
|
||||
Some(annotation) => {
|
||||
def_aliases = annotation.aliases.clone();
|
||||
|
||||
let arity = annotation.arity();
|
||||
let arity = annotation.signature.arity();
|
||||
let rigids = &env.rigids;
|
||||
let mut ftv = rigids.clone();
|
||||
|
||||
let annotation = instantiate_rigids(
|
||||
annotation,
|
||||
&introduced_vars,
|
||||
let signature = instantiate_rigids(
|
||||
&annotation.signature,
|
||||
&annotation.introduced_variables,
|
||||
&mut new_rigids,
|
||||
&mut ftv,
|
||||
&def.loc_pattern,
|
||||
|
@ -954,8 +960,10 @@ fn constrain_def(env: &Env, def: &Def, body_con: Constraint) -> Constraint {
|
|||
let annotation_expected = FromAnnotation(
|
||||
def.loc_pattern.clone(),
|
||||
arity,
|
||||
AnnotationSource::TypedBody,
|
||||
annotation,
|
||||
AnnotationSource::TypedBody {
|
||||
region: annotation.region,
|
||||
},
|
||||
signature,
|
||||
);
|
||||
|
||||
pattern_state.constraints.push(Eq(
|
||||
|
@ -1106,17 +1114,17 @@ pub fn rec_defs_help(
|
|||
flex_info.def_types.extend(pattern_state.headers);
|
||||
}
|
||||
|
||||
Some((annotation, introduced_vars, ann_def_aliases)) => {
|
||||
for (symbol, alias) in ann_def_aliases.clone() {
|
||||
Some(annotation) => {
|
||||
for (symbol, alias) in annotation.aliases.clone() {
|
||||
def_aliases.insert(symbol, alias);
|
||||
}
|
||||
|
||||
let arity = annotation.arity();
|
||||
let arity = annotation.signature.arity();
|
||||
let mut ftv = env.rigids.clone();
|
||||
|
||||
let annotation = instantiate_rigids(
|
||||
annotation,
|
||||
&introduced_vars,
|
||||
let signature = instantiate_rigids(
|
||||
&annotation.signature,
|
||||
&annotation.introduced_variables,
|
||||
&mut new_rigids,
|
||||
&mut ftv,
|
||||
&def.loc_pattern,
|
||||
|
@ -1126,8 +1134,10 @@ pub fn rec_defs_help(
|
|||
let annotation_expected = FromAnnotation(
|
||||
def.loc_pattern.clone(),
|
||||
arity,
|
||||
AnnotationSource::TypedBody,
|
||||
annotation.clone(),
|
||||
AnnotationSource::TypedBody {
|
||||
region: annotation.region,
|
||||
},
|
||||
signature.clone(),
|
||||
);
|
||||
let expr_con = constrain_expr(
|
||||
&Env {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue