mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-24 20:42:29 +00:00
Recover Erroneous in type
This commit is contained in:
parent
58020a55d6
commit
e240b18b27
2 changed files with 11 additions and 2 deletions
|
@ -3040,7 +3040,6 @@ fn type_to_variable<'a>(
|
||||||
alias_variable,
|
alias_variable,
|
||||||
AliasKind::Structural,
|
AliasKind::Structural,
|
||||||
);
|
);
|
||||||
// let result = register(subs, rank, pools, content);
|
|
||||||
let result = register_with_known_var(subs, destination, rank, pools, content);
|
let result = register_with_known_var(subs, destination, rank, pools, content);
|
||||||
|
|
||||||
// We only want to unify the actual_var with the alias once
|
// We only want to unify the actual_var with the alias once
|
||||||
|
@ -3054,7 +3053,11 @@ fn type_to_variable<'a>(
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
Erroneous => {
|
Erroneous => {
|
||||||
let content = Content::Error;
|
// TODO: remove `Erroneous`, `Error` can always be used, and type problems known at
|
||||||
|
// this point can be reported during canonicalization.
|
||||||
|
let problem_index =
|
||||||
|
SubsIndex::push_new(&mut subs.problems, types.get_problem(&typ).clone());
|
||||||
|
let content = Content::Structure(FlatType::Erroneous(problem_index));
|
||||||
|
|
||||||
register_with_known_var(subs, destination, rank, pools, content)
|
register_with_known_var(subs, destination, rank, pools, content)
|
||||||
}
|
}
|
||||||
|
|
|
@ -417,6 +417,7 @@ pub enum TypeTag {
|
||||||
Variable(Variable),
|
Variable(Variable),
|
||||||
RangedNumber(NumericRange),
|
RangedNumber(NumericRange),
|
||||||
/// A type error, which will code gen to a runtime error
|
/// A type error, which will code gen to a runtime error
|
||||||
|
/// The problem is at the index of the type tag
|
||||||
Erroneous,
|
Erroneous,
|
||||||
|
|
||||||
// TypeExtension is implicit in the type slice
|
// TypeExtension is implicit in the type slice
|
||||||
|
@ -507,6 +508,11 @@ impl Types {
|
||||||
.expect("typ is not a single tag union")
|
.expect("typ is not a single tag union")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[track_caller]
|
||||||
|
pub fn get_problem(&self, typ: &Index<TypeTag>) -> &Problem {
|
||||||
|
self.problems.get(typ).expect("typ is not an error")
|
||||||
|
}
|
||||||
|
|
||||||
pub fn record_fields_slices(
|
pub fn record_fields_slices(
|
||||||
&self,
|
&self,
|
||||||
fields: RecordFields,
|
fields: RecordFields,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue