Skip to content

Commit

Permalink
fix(check): Don't bail out if record fields are undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
Marwes committed Feb 24, 2018
1 parent 1c001b1 commit e0863b9
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions check/src/typecheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -966,9 +966,24 @@ impl<'a> Typecheck<'a> {
*typ = self.create_unifiable_signature(typ)
.unwrap_or_else(|| typ.clone());
}
let alias = self.find_type_info(&field.name.value)?.clone();
if self.error_on_duplicated_field(&mut duplicated_fields, field.name.clone()) {
new_types.push(Field::new(field.name.value.clone(), alias));

match self.find_type_info(&field.name.value)
.map(|alias| alias.clone())
{
Ok(alias) => {
if self.error_on_duplicated_field(
&mut duplicated_fields,
field.name.clone(),
) {
new_types.push(Field::new(field.name.value.clone(), alias));
}
}
Err(err) => {
self.errors.push(Spanned {
span: field.name.span,
value: err.into(),
});
}
}
}

Expand All @@ -993,7 +1008,7 @@ impl<'a> Typecheck<'a> {
new_skolem_scope(&self.subs, &FnvMap::default(), &typ)
}
None => {
let typ = self.find(&field.name.value)?;
let typ = self.find_at(field.name.span, &field.name.value);
match expected_field_type {
Some(expected_field_type) => {
self.subsumes(field.name.span, level, &expected_field_type, typ)
Expand Down

0 comments on commit e0863b9

Please sign in to comment.