Skip to content

Commit 40aea56

Browse files
committed
Better error message on internal error for an array without any index
1 parent c715b9f commit 40aea56

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

vhdl_lang/src/analysis/range.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,21 @@ impl<'a> AnalyzeContext<'a> {
117117
};
118118

119119
if let Some((_, indexes)) = typ.array_type() {
120-
if let Some(first) = indexes.first().unwrap() {
121-
Ok(*first)
120+
if let Some(first) = indexes.first() {
121+
if let Some(base_type) = first {
122+
Ok(*base_type)
123+
} else {
124+
// There was probably an error in the type definition of this signal/variable
125+
Err(EvalError::Unknown)
126+
}
122127
} else {
123-
// There was probably an error in the type definition of this signal/variable
128+
// This should never happen
129+
if let Some(decl_pos) = typ.decl_pos() {
130+
// To debug if it ever happens
131+
eprintln!("{}", decl_pos.show("Array with no indexes"));
132+
eprintln!("{}", attr.name.pos.show("Used here"));
133+
panic!("Internal error")
134+
}
124135
Err(EvalError::Unknown)
125136
}
126137
} else {

0 commit comments

Comments
 (0)