Implement most of the recent round of PR feedback

This commit is contained in:
Sam Mohr 2024-10-26 04:17:50 -07:00
parent 03f83a0ba8
commit 6a2ffb2f5a
No known key found for this signature in database
GPG key ID: EA41D161A3C1BC99
13 changed files with 67 additions and 116 deletions

View file

@ -248,6 +248,9 @@ pub enum Problem {
StatementsAfterReturn {
region: Region,
},
ReturnAtEndOfFunction {
region: Region,
},
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@ -331,6 +334,7 @@ impl Problem {
Problem::FileProblem { .. } => Fatal,
Problem::ReturnOutsideOfFunction { .. } => Warning,
Problem::StatementsAfterReturn { .. } => Warning,
Problem::ReturnAtEndOfFunction { .. } => Warning,
}
}
@ -442,7 +446,6 @@ impl Problem {
field: region,
})
| Problem::RuntimeError(RuntimeError::ReadIngestedFileError { region, .. })
| Problem::RuntimeError(RuntimeError::ReturnOutsideOfFunction(region))
| Problem::InvalidAliasRigid { region, .. }
| Problem::InvalidInterpolation(region)
| Problem::InvalidHexadecimal(region)
@ -496,7 +499,8 @@ impl Problem {
| Problem::UnappliedDbg { region }
| Problem::DefsOnlyUsedInRecursion(_, region)
| Problem::ReturnOutsideOfFunction { region }
| Problem::StatementsAfterReturn { region } => Some(*region),
| Problem::StatementsAfterReturn { region }
| Problem::ReturnAtEndOfFunction { region } => Some(*region),
Problem::RuntimeError(RuntimeError::CircularDef(cycle_entries))
| Problem::BadRecursion(cycle_entries) => {
cycle_entries.first().map(|entry| entry.expr_region)
@ -703,8 +707,6 @@ pub enum RuntimeError {
},
MalformedSuffixed(Region),
ReturnOutsideOfFunction(Region),
}
impl RuntimeError {
@ -753,8 +755,7 @@ impl RuntimeError {
record: _,
field: region,
}
| RuntimeError::ReadIngestedFileError { region, .. }
| RuntimeError::ReturnOutsideOfFunction(region) => *region,
| RuntimeError::ReadIngestedFileError { region, .. } => *region,
RuntimeError::InvalidUnicodeCodePt(region) => *region,
RuntimeError::UnresolvedTypeVar | RuntimeError::ErroneousType => Region::zero(),
RuntimeError::LookupNotInScope { loc_name, .. } => loc_name.region,