switch from type annotation to type variable

This commit is contained in:
Brendan Hansknecht 2023-04-06 20:17:22 -07:00
parent 8f4945f286
commit 6302a8d4b5
No known key found for this signature in database
GPG key ID: 0EA784685083E75B
11 changed files with 136 additions and 97 deletions

View file

@ -1,4 +1,5 @@
use std::cell::Cell;
use std::path::Path;
use crate::abilities::SpecializationId;
use crate::exhaustive::{ExhaustiveContext, SketchedRows};
@ -599,6 +600,7 @@ impl Constraints {
| Constraint::PatternPresence(_, _, _, _)
| Constraint::Exhaustive { .. }
| Constraint::Resolve(..)
| Constraint::IngestedFile(..)
| Constraint::CheckCycle(..) => false,
}
}
@ -673,10 +675,19 @@ impl Constraints {
Constraint::CheckCycle(cycle_index, cycle_mark)
}
pub fn ingested_file(
&mut self,
type_index: TypeOrVar,
file_path: Box<Path>,
bytes: Vec<u8>,
) -> Constraint {
Constraint::IngestedFile(type_index, file_path, bytes)
}
}
roc_error_macros::assert_sizeof_default!(Constraint, 3 * 8);
roc_error_macros::assert_sizeof_aarch64!(Constraint, 3 * 8);
roc_error_macros::assert_sizeof_default!(Constraint, 6 * 8);
roc_error_macros::assert_sizeof_aarch64!(Constraint, 6 * 8);
impl std::ops::Index<ExpectedTypeIndex> for Constraints {
type Output = Expected<TypeOrVar>;
@ -734,7 +745,7 @@ pub struct OpportunisticResolve {
pub specialization_id: SpecializationId,
}
#[derive(Clone, Copy)]
#[derive(Clone)]
pub enum Constraint {
Eq(Eq),
Store(TypeOrVar, Variable, Index<&'static str>, u32),
@ -773,6 +784,10 @@ pub enum Constraint {
/// Attempt to resolve a specialization.
Resolve(OpportunisticResolve),
CheckCycle(Index<Cycle>, IllegalCycleMark),
// This is terrible and could be a huge cost to copy.
// Not sure a better way to get the bytes here so we can check if they are valid utf8 or decode properly.
IngestedFile(TypeOrVar, Box<Path>, Vec<u8>),
}
#[derive(Debug, Clone, Copy, Default)]
@ -856,6 +871,9 @@ impl std::fmt::Debug for Constraint {
Self::CheckCycle(arg0, arg1) => {
write!(f, "CheckCycle({:?}, {:?})", arg0, arg1)
}
Self::IngestedFile(arg0, arg1, arg2) => {
write!(f, "IngestedFile({:?}, {:?}, {:?})", arg0, arg1, arg2)
}
}
}
}