hdl icon indicating copy to clipboard operation
hdl copied to clipboard

General generic-related error reporting improvements

Open Jacajack opened this issue 2 years ago • 1 comments

Feature description

I know this is probably a big one (but not sure), but it would be nice if the compiler could print values of relevant generic variables when reporting errors. For example in this code:

module X {}

impl X {
	const ubus<4> arr[4];

	for (i in [0:<4]) {
		ubus<(i+2)> x = 0;
		arr[i] = ext(x);
	}
}

We get this moderately helpful error message:

Error: 
  × In assignments, the width of the left-hand side must match the width of the right-hand side
    ╭─[tests/input/ignore/jesus.hirl:45:1]
 45 │         ubus<(i+2)> x = 0;
 46 │         arr[i] = ext(x);
    ·                      ┬
    ·                      ╰── You cannot shrink the width of the signal
 47 │     }
    ╰────
  help: Please make sure that all bonded signals have the same width

Perhaps it would be sufficient to get all generic variables which appear in the expression and print their values. Printing values of iterators in case of nested for loops would be beneficial as well.

Jacajack avatar Nov 21 '23 18:11 Jacajack

By the way the ext() error could also contain information about the argument and destination widths.

Jacajack avatar Nov 21 '23 18:11 Jacajack