Improve shadow errors

This commit is contained in:
ayazhafiz 2022-04-07 22:38:20 -04:00
parent 13a17f1858
commit 94a5cd3559
8 changed files with 57 additions and 21 deletions

View file

@ -20,6 +20,14 @@ pub enum BadPattern {
Unsupported(PatternType),
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ShadowKind {
Variable,
Alias,
Opaque,
Ability,
}
/// Problems that can occur in the course of canonicalization.
#[derive(Clone, Debug, PartialEq)]
pub enum Problem {
@ -33,9 +41,10 @@ pub enum Problem {
PrecedenceProblem(PrecedenceProblem),
// Example: (5 = 1 + 2) is an unsupported pattern in an assignment; Int patterns aren't allowed in assignments!
UnsupportedPattern(BadPattern, Region),
ShadowingInAnnotation {
Shadowing {
original_region: Region,
shadow: Loc<Ident>,
kind: ShadowKind,
},
CyclicAlias(Symbol, Region, Vec<Symbol>),
BadRecursion(Vec<CycleEntry>),
@ -181,6 +190,7 @@ pub enum RuntimeError {
Shadowing {
original_region: Region,
shadow: Loc<Ident>,
kind: ShadowKind,
},
InvalidOptionalValue {
field_name: Lowercase,