Constrain + solve crash

This commit is contained in:
Ayaz Hafiz 2022-11-02 16:05:13 -05:00
parent 9dc489c2b0
commit e2b30e5301
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
13 changed files with 194 additions and 60 deletions

View file

@ -994,7 +994,6 @@ impl Types {
self.set_type_tag(index, TypeTag::RangedNumber(*range), Slice::default())
}
Type::Error => self.set_type_tag(index, TypeTag::Error, Slice::default()),
Type::Crash => todo!(),
}
}
@ -1669,7 +1668,6 @@ pub enum Type {
Apply(Symbol, Vec<Loc<Type>>, Region),
Variable(Variable),
RangedNumber(NumericRange),
Crash, // Str -> a
/// A type error, which will code gen to a runtime error
Error,
}
@ -1712,7 +1710,6 @@ impl Clone for Type {
match self {
Self::EmptyRec => Self::EmptyRec,
Self::EmptyTagUnion => Self::EmptyTagUnion,
Self::Crash => Self::Crash,
Self::Function(arg0, arg1, arg2) => {
Self::Function(arg0.clone(), arg1.clone(), arg2.clone())
}
@ -2081,7 +2078,6 @@ impl fmt::Debug for Type {
Type::RangedNumber(range_vars) => {
write!(f, "Ranged({:?})", range_vars)
}
Type::Crash => write!(f, "Crash"),
Type::UnspecializedLambdaSet { unspecialized } => {
write!(f, "{:?}", unspecialized)
}
@ -2245,7 +2241,7 @@ impl Type {
);
}
EmptyRec | EmptyTagUnion | Crash | Error => {}
EmptyRec | EmptyTagUnion | Error => {}
}
}
}
@ -2375,7 +2371,7 @@ impl Type {
);
}
EmptyRec | EmptyTagUnion | Crash | Error => {}
EmptyRec | EmptyTagUnion | Error => {}
}
}
}
@ -2478,7 +2474,7 @@ impl Type {
}
RangedNumber(_) => Ok(()),
UnspecializedLambdaSet { .. } => Ok(()),
EmptyRec | EmptyTagUnion | ClosureTag { .. } | Error | Variable(_) | Crash => Ok(()),
EmptyRec | EmptyTagUnion | ClosureTag { .. } | Error | Variable(_) => Ok(()),
}
}
@ -2540,7 +2536,7 @@ impl Type {
UnspecializedLambdaSet {
unspecialized: Uls(_, sym, _),
} => *sym == rep_symbol,
EmptyRec | EmptyTagUnion | ClosureTag { .. } | Error | Variable(_) | Crash => false,
EmptyRec | EmptyTagUnion | ClosureTag { .. } | Error | Variable(_) => false,
}
}
@ -2596,7 +2592,7 @@ impl Type {
.iter()
.any(|arg| arg.value.contains_variable(rep_variable)),
RangedNumber(_) => false,
EmptyRec | EmptyTagUnion | Error | Crash => false,
EmptyRec | EmptyTagUnion | Error => false,
}
}
@ -2970,7 +2966,7 @@ impl Type {
}
RangedNumber(_) => {}
UnspecializedLambdaSet { .. } => {}
EmptyRec | EmptyTagUnion | ClosureTag { .. } | Error | Variable(_) | Crash => {}
EmptyRec | EmptyTagUnion | ClosureTag { .. } | Error | Variable(_) => {}
}
}
@ -3106,7 +3102,7 @@ fn symbols_help(initial: &Type) -> Vec<Symbol> {
} => {
// ignore the member symbol because unspecialized lambda sets are internal-only
}
EmptyRec | EmptyTagUnion | ClosureTag { .. } | Error | Variable(_) | Crash => {}
EmptyRec | EmptyTagUnion | ClosureTag { .. } | Error | Variable(_) => {}
}
}
@ -3222,7 +3218,7 @@ fn variables_help(tipe: &Type, accum: &mut ImSet<Variable>) {
}
variables_help(actual, accum);
}
RangedNumber(_) | Crash => {}
RangedNumber(_) => {}
Apply(_, args, _) => {
for x in args {
variables_help(&x.value, accum);
@ -3250,7 +3246,7 @@ fn variables_help_detailed(tipe: &Type, accum: &mut VariableDetail) {
use Type::*;
match tipe {
EmptyRec | EmptyTagUnion | Error | Crash => (),
EmptyRec | EmptyTagUnion | Error => (),
Variable(v) => {
accum.type_variables.insert(*v);
@ -3490,6 +3486,7 @@ pub enum Reason {
member_name: Symbol,
def_region: Region,
},
CrashArg,
}
#[derive(PartialEq, Eq, Debug, Clone)]
@ -4377,7 +4374,6 @@ fn instantiate_lambda_sets_as_unspecialized(
match typ {
Type::EmptyRec => {}
Type::EmptyTagUnion => {}
Type::Crash => {}
Type::Function(args, lambda_set, ret) => {
debug_assert!(
matches!(**lambda_set, Type::Variable(..)),