Allow ignored defs with an effectful RHS

This commit is contained in:
Agus Zubiaga 2024-10-24 00:24:49 -03:00
parent 175a2b5683
commit c9f001b041
No known key found for this signature in database
13 changed files with 136 additions and 126 deletions

View file

@ -663,7 +663,7 @@ impl Constraints {
| Constraint::Store(..)
| Constraint::Lookup(..)
| Constraint::Pattern(..)
| Constraint::EffectfulStmt(..)
| Constraint::ExpectEffectful(..)
| Constraint::FxCall(_)
| Constraint::FxSuffix(_)
| Constraint::FlexToPure(_)
@ -845,8 +845,8 @@ pub enum Constraint {
FxSuffix(Index<FxSuffixConstraint>),
/// Set an fx var as pure if flex (no effectful functions were called)
FlexToPure(Variable),
/// Expect statement to be effectful
EffectfulStmt(Variable, Region),
/// Expect statement or ignored def to be effectful
ExpectEffectful(Variable, ExpectEffectfulReason, Region),
/// Used for things that always unify, e.g. blanks and runtime errors
True,
SaveTheEnvironment,
@ -937,6 +937,7 @@ pub struct FxExpectation {
pub enum FxCallKind {
Call(Option<Symbol>),
Stmt,
Ignored,
}
#[derive(Debug, Clone, Copy)]
@ -962,6 +963,12 @@ impl FxSuffixKind {
}
}
#[derive(Debug, Clone, Copy)]
pub enum ExpectEffectfulReason {
Stmt,
Ignored,
}
/// Custom impl to limit vertical space used by the debug output
impl std::fmt::Debug for Constraint {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
@ -984,8 +991,8 @@ impl std::fmt::Debug for Constraint {
Self::FxSuffix(arg0) => {
write!(f, "FxSuffix({arg0:?})")
}
Self::EffectfulStmt(arg0, arg1) => {
write!(f, "EffectfulStmt({arg0:?}, {arg1:?})")
Self::ExpectEffectful(arg0, arg1, arg2) => {
write!(f, "EffectfulStmt({arg0:?}, {arg1:?}, {arg2:?})")
}
Self::FlexToPure(arg0) => {
write!(f, "FlexToPure({arg0:?})")