Allow unsuffixed statements in parser

Moves the "STATEMENT AFTER EXPRESSION" error from the parser to canonicalization.
We'll later use this to allow this case in effectful functions.
This commit is contained in:
Agus Zubiaga 2024-10-14 20:05:33 -03:00
parent f677592f97
commit 2cce5ad023
No known key found for this signature in database
23 changed files with 280 additions and 107 deletions

View file

@ -251,6 +251,7 @@ pub enum Problem {
ReturnAtEndOfFunction {
region: Region,
},
StmtAfterExpr(Region),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@ -335,6 +336,7 @@ impl Problem {
Problem::ReturnOutsideOfFunction { .. } => Warning,
Problem::StatementsAfterReturn { .. } => Warning,
Problem::ReturnAtEndOfFunction { .. } => Warning,
Problem::StmtAfterExpr(_) => Fatal,
}
}
@ -505,6 +507,7 @@ impl Problem {
| Problem::BadRecursion(cycle_entries) => {
cycle_entries.first().map(|entry| entry.expr_region)
}
Problem::StmtAfterExpr(region) => Some(*region),
Problem::RuntimeError(RuntimeError::UnresolvedTypeVar)
| Problem::RuntimeError(RuntimeError::ErroneousType)
| Problem::RuntimeError(RuntimeError::NonExhaustivePattern)