Print multiple abilities in error types

This commit is contained in:
Ayaz Hafiz 2022-10-12 15:38:16 -05:00
parent 94fc58a508
commit 49e19d96e5
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
3 changed files with 62 additions and 30 deletions

View file

@ -3738,14 +3738,14 @@ fn content_to_err_type(
}
};
// TODO(multi-abilities)
ErrorType::FlexAbleVar(name, subs.get_subs_slice(abilities)[0])
let ability_set = AbilitySet::from_iter(subs.get_subs_slice(abilities).iter().copied());
ErrorType::FlexAbleVar(name, ability_set)
}
RigidAbleVar(name_index, abilities) => {
let name = subs.field_names[name_index.index as usize].clone();
// TODO(multi-abilities)
ErrorType::RigidAbleVar(name, subs.get_subs_slice(abilities)[0])
let ability_set = AbilitySet::from_iter(subs.get_subs_slice(abilities).iter().copied());
ErrorType::RigidAbleVar(name, ability_set)
}
RecursionVar {

View file

@ -256,7 +256,7 @@ pub struct AliasCommon {
///
/// In the future we might want to do some small-vec optimizations, though that may be trivialized
/// away with a SoA representation of canonicalized types.
#[derive(Clone, Debug, Default, PartialEq, PartialOrd, Eq, Ord)]
#[derive(Clone, Debug, Default, PartialEq, PartialOrd, Eq, Ord, Hash)]
pub struct AbilitySet(Vec<Symbol>);
impl AbilitySet {
@ -282,11 +282,11 @@ impl AbilitySet {
self.0.contains(ability)
}
pub fn sorted_iter(&self) -> impl Iterator<Item = &Symbol> {
pub fn sorted_iter(&self) -> impl ExactSizeIterator<Item = &Symbol> {
self.0.iter()
}
pub fn into_sorted_iter(self) -> impl Iterator<Item = Symbol> {
pub fn into_sorted_iter(self) -> impl ExactSizeIterator<Item = Symbol> {
self.0.into_iter()
}
}
@ -2266,8 +2266,8 @@ pub enum ErrorType {
Type(Symbol, Vec<ErrorType>),
FlexVar(Lowercase),
RigidVar(Lowercase),
FlexAbleVar(Lowercase, Symbol),
RigidAbleVar(Lowercase, Symbol),
FlexAbleVar(Lowercase, AbilitySet),
RigidAbleVar(Lowercase, AbilitySet),
Record(SendMap<Lowercase, RecordField<ErrorType>>, TypeExt),
TagUnion(SendMap<TagName, Vec<ErrorType>>, TypeExt),
RecursiveTagUnion(Box<ErrorType>, SendMap<TagName, Vec<ErrorType>>, TypeExt),