tamer: asg::air::air: Eliminate todo! for unexpected AirIdent
I had apparently forgotten about this, because I didn't benefit from the exhaustiveness check; this needs to be eliminated so that this doesn't happen again, and to provide a proper non-panicking error. DEV-13162main
parent
4ec4857360
commit
5f275fb801
|
@ -310,7 +310,9 @@ impl ParseState for AirAggregate {
|
|||
Transition(Toplevel(oi_pkg)).incomplete()
|
||||
}
|
||||
|
||||
(st, tok @ AirIdent(..)) => todo!("{st:?}, {tok:?}"),
|
||||
(st @ (Empty | PkgExpr(..) | PkgTpl(..)), AirIdent(tok)) => {
|
||||
Transition(st).err(AsgError::UnexpectedOpaqueIdent(tok.name()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -825,3 +825,18 @@ sum_ir! {
|
|||
/// Tokens that may be used to define or apply templates.
|
||||
pub sum enum AirBindableTpl = AirTpl | AirBind | AirDoc;
|
||||
}
|
||||
|
||||
impl AirIdent {
|
||||
/// Name of the identifier described by this token.
|
||||
pub fn name(&self) -> SPair {
|
||||
use AirIdent::*;
|
||||
|
||||
match self {
|
||||
IdentDecl(name, _, _)
|
||||
| IdentExternDecl(name, _, _)
|
||||
| IdentDep(name, _)
|
||||
| IdentFragment(name, _)
|
||||
| IdentRoot(name) => *name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,6 +155,9 @@ pub enum AsgError {
|
|||
/// depends on first having computed itself,
|
||||
/// which is not possible.
|
||||
UnsupportedCycle(Cycle),
|
||||
|
||||
/// An opaque identifier was declared in an invalid context.
|
||||
UnexpectedOpaqueIdent(SPair),
|
||||
}
|
||||
|
||||
impl Display for AsgError {
|
||||
|
@ -212,6 +215,13 @@ impl Display for AsgError {
|
|||
UnsupportedCycle(cycle) => {
|
||||
write!(f, "circular dependency: {cycle}")
|
||||
}
|
||||
UnexpectedOpaqueIdent(name) => {
|
||||
write!(
|
||||
f,
|
||||
"opaque identifier {} declaration",
|
||||
TtQuote::wrap(name)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -371,6 +381,12 @@ impl Diagnostic for AsgError {
|
|||
|
||||
desc
|
||||
}
|
||||
// TODO: This doesn't seem all that helpful.
|
||||
// What are the circumstances under which this can be hit,
|
||||
// and what additional information can we provide?
|
||||
UnexpectedOpaqueIdent(name) => vec![name.error(
|
||||
"an opaque identifier declaration was not expected here",
|
||||
)],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue