Skip to content

Commit

Permalink
Better error message on internal error for an array without any index
Browse files Browse the repository at this point in the history
  • Loading branch information
kraigher committed Nov 8, 2023
1 parent c715b9f commit 40aea56
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions vhdl_lang/src/analysis/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,21 @@ impl<'a> AnalyzeContext<'a> {
};

if let Some((_, indexes)) = typ.array_type() {
if let Some(first) = indexes.first().unwrap() {
Ok(*first)
if let Some(first) = indexes.first() {
if let Some(base_type) = first {
Ok(*base_type)
} else {
// There was probably an error in the type definition of this signal/variable
Err(EvalError::Unknown)
}
} else {
// There was probably an error in the type definition of this signal/variable
// This should never happen
if let Some(decl_pos) = typ.decl_pos() {
// To debug if it ever happens
eprintln!("{}", decl_pos.show("Array with no indexes"));
eprintln!("{}", attr.name.pos.show("Used here"));
panic!("Internal error")
}
Err(EvalError::Unknown)
}
} else {
Expand Down

0 comments on commit 40aea56

Please sign in to comment.