Use new try impl for ? operator

This commit is contained in:
Sam Mohr 2024-12-05 02:13:08 -08:00
parent 193c23bac8
commit de626102c8
No known key found for this signature in database
GPG key ID: EA41D161A3C1BC99
20 changed files with 429 additions and 110 deletions

View file

@ -2,6 +2,7 @@
use std::{path::PathBuf, str::Utf8Error};
use roc_can::constraint::{ExpectEffectfulReason, FxSuffixKind};
use roc_can::expr::TryKind;
use roc_can::{
constraint::FxCallKind,
expected::{Expected, PExpected},
@ -48,7 +49,7 @@ pub enum TypeError {
ExpectedEffectful(Region, ExpectEffectfulReason),
UnsuffixedEffectfulFunction(Region, FxSuffixKind),
SuffixedPureFunction(Region, FxSuffixKind),
InvalidTryTarget(Region, ErrorType),
InvalidTryTarget(Region, ErrorType, TryKind),
}
impl TypeError {
@ -78,7 +79,7 @@ impl TypeError {
TypeError::FxInTopLevel(_, _) => Warning,
TypeError::UnsuffixedEffectfulFunction(_, _) => Warning,
TypeError::SuffixedPureFunction(_, _) => Warning,
TypeError::InvalidTryTarget(_, _) => RuntimeError,
TypeError::InvalidTryTarget(_, _, _) => RuntimeError,
}
}
@ -100,7 +101,7 @@ impl TypeError {
| TypeError::ExpectedEffectful(region, _)
| TypeError::UnsuffixedEffectfulFunction(region, _)
| TypeError::SuffixedPureFunction(region, _)
| TypeError::InvalidTryTarget(region, _) => Some(*region),
| TypeError::InvalidTryTarget(region, _, _) => Some(*region),
TypeError::UnfulfilledAbility(ab, ..) => ab.region(),
TypeError::Exhaustive(e) => Some(e.region()),
TypeError::CircularDef(c) => c.first().map(|ce| ce.symbol_region),