Remove FlatType::Erroneous

This commit is contained in:
Ayaz Hafiz 2022-11-08 13:31:22 -06:00
parent 1974d8e848
commit 281bc94b55
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
13 changed files with 12 additions and 60 deletions

View file

@ -1455,8 +1455,6 @@ fn adjust_rank_content(
rank
}
Erroneous(_) => group_rank,
}
}
@ -1595,7 +1593,7 @@ fn instantiate_rigids_help(
}
}
EmptyRecord | EmptyTagUnion | Erroneous(_) => {}
EmptyRecord | EmptyTagUnion => {}
Record(fields, ext_var) => {
for index in fields.iter_variables() {
@ -1775,7 +1773,7 @@ fn deep_copy_var_help(
Func(arg_vars, new_closure_var, new_ret_var)
}
same @ EmptyRecord | same @ EmptyTagUnion | same @ Erroneous(_) => same,
same @ EmptyRecord | same @ EmptyTagUnion => same,
Record(fields, ext_var) => {
let record_fields = {

View file

@ -844,7 +844,7 @@ fn deep_copy_type_vars<C: CopyEnv>(
// Everything else is a mechanical descent.
Structure(flat_type) => match flat_type {
EmptyRecord | EmptyTagUnion | Erroneous(_) => Structure(flat_type),
EmptyRecord | EmptyTagUnion => Structure(flat_type),
Apply(symbol, arguments) => {
descend_slice!(arguments);

View file

@ -148,7 +148,6 @@ fn index_var(
FlatType::Func(_, _, _) | FlatType::FunctionOrTagUnion(_, _, _) => {
return Err(TypeError)
}
FlatType::Erroneous(_) => return Err(TypeError),
FlatType::Apply(Symbol::LIST_LIST, args) => {
match (subs.get_subs_slice(*args), ctor) {
([elem_var], IndexCtor::List) => {

View file

@ -72,7 +72,6 @@ impl FlatDecodable {
Err(Underivable) // yet
}
//
FlatType::Erroneous(_) => Err(Underivable),
FlatType::Func(..) => Err(Underivable),
},
Content::Alias(sym, _, real_var, _) => match sym {

View file

@ -106,7 +106,6 @@ impl FlatEncodable {
FlatType::EmptyRecord => Ok(Key(FlatEncodableKey::Record(vec![]))),
FlatType::EmptyTagUnion => Ok(Key(FlatEncodableKey::TagUnion(vec![]))),
//
FlatType::Erroneous(_) => Err(Underivable),
FlatType::Func(..) => Err(Underivable),
},
Content::Alias(sym, _, real_var, _) => match sym {

View file

@ -103,7 +103,6 @@ impl FlatHash {
FlatType::EmptyRecord => Ok(Key(FlatHashKey::Record(vec![]))),
FlatType::EmptyTagUnion => Ok(Key(FlatHashKey::TagUnion(vec![]))),
//
FlatType::Erroneous(_) => Err(Underivable),
FlatType::Func(..) => Err(Underivable),
},
Content::Alias(sym, _, real_var, _) => match sym {

View file

@ -1979,7 +1979,7 @@ fn lambda_set_size(subs: &Subs, var: Variable) -> (usize, usize, usize) {
}
stack.push((*ext, depth_any + 1, depth_lset));
}
FlatType::Erroneous(_) | FlatType::EmptyRecord | FlatType::EmptyTagUnion => {}
FlatType::EmptyRecord | FlatType::EmptyTagUnion => {}
},
Content::FlexVar(_)
| Content::RigidVar(_)
@ -3188,7 +3188,6 @@ fn layout_from_flat_type<'a>(
layout_from_recursive_union(env, rec_var, &tags)
}
EmptyTagUnion => cacheable(Ok(Layout::VOID)),
Erroneous(_) => cacheable(Err(LayoutProblem::Erroneous)),
EmptyRecord => cacheable(Ok(Layout::UNIT)),
}
}

View file

@ -189,8 +189,6 @@ impl FunctionLayout {
})
}
FlatType::Erroneous(_) => Err(TypeError(())),
_ => todo!(),
}
}
@ -867,7 +865,6 @@ impl Layout {
Ok(Layout::UnionRecursive(slices))
}
FlatType::Erroneous(_) => Err(TypeError(())),
FlatType::EmptyRecord => Ok(Layout::UNIT),
FlatType::EmptyTagUnion => Ok(Layout::VOID),
}

View file

@ -715,13 +715,6 @@ trait DerivableVisitor {
}
EmptyRecord => Self::visit_empty_record(var)?,
EmptyTagUnion => Self::visit_empty_tag_union(var)?,
Erroneous(_) => {
return Err(NotDerivable {
var,
context: NotDerivableContext::NoContext,
})
}
},
Alias(
Symbol::NUM_NUM | Symbol::NUM_INTEGER | Symbol::NUM_FLOATINGPOINT,

View file

@ -1490,13 +1490,7 @@ fn solve(
let branches_content = subs.get_content_without_compacting(branches_var);
let already_have_error = matches!(
(real_content, branches_content),
(
Content::Error | Content::Structure(FlatType::Erroneous(_)),
_
) | (
_,
Content::Error | Content::Structure(FlatType::Erroneous(_))
)
(Content::Error, _) | (_, Content::Error)
);
let snapshot = subs.snapshot();
@ -3826,8 +3820,6 @@ fn adjust_rank_content(
rank
}
Erroneous(_) => group_rank,
}
}
@ -4076,7 +4068,7 @@ fn deep_copy_var_help(
Func(new_arguments, new_closure_var, new_ret_var)
}
same @ EmptyRecord | same @ EmptyTagUnion | same @ Erroneous(_) => same,
same @ EmptyRecord | same @ EmptyTagUnion => same,
Record(fields, ext_var) => {
let record_fields = {

View file

@ -408,7 +408,7 @@ fn find_names_needed(
find_under_alias,
);
}
Error | Structure(Erroneous(_)) | Structure(EmptyRecord) | Structure(EmptyTagUnion) => {
Error | Structure(EmptyRecord) | Structure(EmptyTagUnion) => {
// Errors and empty records don't need names.
}
}
@ -1284,7 +1284,6 @@ fn write_flat_type<'a>(
)
})
}
Erroneous(problem) => write!(buf, "<Type Mismatch: {:?}>", problem).unwrap(),
}
}

View file

@ -975,7 +975,6 @@ fn subs_fmt_flat_type(this: &FlatType, subs: &Subs, f: &mut fmt::Formatter) -> f
write!(f, "]<{:?}> as <{:?}>", new_ext, rec)
}
FlatType::Erroneous(e) => write!(f, "Erroneous({:?})", e),
FlatType::EmptyRecord => write!(f, "EmptyRecord"),
FlatType::EmptyTagUnion => write!(f, "EmptyTagUnion"),
}
@ -2517,7 +2516,6 @@ pub enum FlatType {
FunctionOrTagUnion(SubsSlice<TagName>, SubsSlice<Symbol>, Variable),
RecursiveTagUnion(Variable, UnionTags, Variable),
Erroneous(SubsIndex<Problem>),
EmptyRecord,
EmptyTagUnion,
}
@ -3274,7 +3272,7 @@ fn occurs(
short_circuit_help(subs, root_var, &new_seen, *ext_var)
}
EmptyRecord | EmptyTagUnion | Erroneous(_) => Ok(()),
EmptyRecord | EmptyTagUnion => Ok(()),
}
}
Alias(_, args, _, _) => {
@ -3445,7 +3443,7 @@ fn explicit_substitute(
subs.set_content(in_var, Structure(Record(vars_by_field, new_ext_var)));
}
EmptyRecord | EmptyTagUnion | Erroneous(_) => {}
EmptyRecord | EmptyTagUnion => {}
}
in_var
@ -3628,9 +3626,7 @@ fn get_var_names(
accum
}
FlatType::EmptyRecord | FlatType::EmptyTagUnion | FlatType::Erroneous(_) => {
taken_names
}
FlatType::EmptyRecord | FlatType::EmptyTagUnion => taken_names,
FlatType::Record(vars_by_field, ext_var) => {
let mut accum = get_var_names(subs, ext_var, taken_names);
@ -4039,8 +4035,6 @@ fn flat_type_to_err_type(
panic!("Tried to convert a recursive tag union extension to an error, but the tag union extension had the ErrorType of {:?}", other)
}
}
Erroneous(_) => ErrorType::Error,
}
}
@ -4320,9 +4314,6 @@ impl StorageSubs {
Self::offset_tag_union(offsets, *union_tags),
Self::offset_variable(offsets, *ext),
),
FlatType::Erroneous(problem) => {
FlatType::Erroneous(Self::offset_problem(offsets, *problem))
}
FlatType::EmptyRecord => FlatType::EmptyRecord,
FlatType::EmptyTagUnion => FlatType::EmptyTagUnion,
}
@ -4606,7 +4597,7 @@ fn storage_copy_var_to_help(env: &mut StorageCopyVarToEnv<'_>, var: Variable) ->
Func(new_arguments, new_closure_var, new_ret_var)
}
same @ EmptyRecord | same @ EmptyTagUnion | same @ Erroneous(_) => same,
same @ EmptyRecord | same @ EmptyTagUnion => same,
Record(fields, ext_var) => {
let record_fields = {
@ -5024,13 +5015,6 @@ fn copy_import_to_help(env: &mut CopyImportEnv<'_>, max_rank: Rank, var: Variabl
// We have already marked the variable as copied, so we
// will not repeat this work or crawl this variable again.
match desc.content {
Structure(Erroneous(_)) => {
// Make this into a flex var so that we don't have to copy problems across module
// boundaries - the error will be reported locally.
env.target.set(copy, make_descriptor(FlexVar(None)));
copy
}
Structure(flat_type) => {
let new_flat_type = match flat_type {
Apply(symbol, arguments) => {
@ -5061,8 +5045,6 @@ fn copy_import_to_help(env: &mut CopyImportEnv<'_>, max_rank: Rank, var: Variabl
Func(new_arguments, new_closure_var, new_ret_var)
}
Erroneous(_) => internal_error!("I thought this was handled above"),
same @ EmptyRecord | same @ EmptyTagUnion => same,
Record(fields, ext_var) => {
@ -5435,8 +5417,6 @@ fn instantiate_rigids_help(subs: &mut Subs, max_rank: Rank, initial: Variable) {
stack.push(ext_var);
stack.push(rec_var);
}
Erroneous(_) => (),
},
Alias(_, args, var, _) => {
let var = *var;
@ -5539,7 +5519,7 @@ pub fn get_member_lambda_sets_at_region(subs: &Subs, var: Variable, target_regio
);
stack.push(*ext);
}
FlatType::Erroneous(_) | FlatType::EmptyRecord | FlatType::EmptyTagUnion => {}
FlatType::EmptyRecord | FlatType::EmptyTagUnion => {}
},
Content::Alias(_, _, real_var, _) => {
stack.push(*real_var);
@ -5606,7 +5586,6 @@ fn is_inhabited(subs: &Subs, var: Variable) -> bool {
}
}
FlatType::FunctionOrTagUnion(_, _, _) => {}
FlatType::Erroneous(_) => {}
FlatType::EmptyRecord => {}
FlatType::EmptyTagUnion => {
return false;

View file

@ -866,7 +866,6 @@ fn add_type_help<'a>(
Content::Structure(FlatType::FunctionOrTagUnion(_, _, _)) => {
todo!()
}
Content::Structure(FlatType::Erroneous(_)) => todo!(),
Content::Structure(FlatType::EmptyRecord) => {
types.add_anonymous(&env.layout_cache.interner, RocType::Unit, layout)
}