xls icon indicating copy to clipboard operation
xls copied to clipboard

DSLX: Instantiating a parametric type with a named conflict causes XlsTypeError

Open RobSpringer opened this issue 2 years ago • 0 comments

In one file, I have a parametric type,

pub struct SlidingWindow<NUM_ELEMENTS: u32> {
  data: Block[NUM_ELEMENTS],
  num_entries: u32,
}

in another file, I instantiate this type via

import sliding_window
type SlidingWindow = sliding_window::SlidingWindow<u32:4>;

This is fine.

But if I instead try

import sliding_window
const NUM_ENTRIES = u32:4;
type SlidingWindow = sliding_window::SlidingWindow<NUM_ENTRIES>;

I get the following error:

XlsTypeError: struct 'SlidingWindow' structure: SlidingWindow { data: uN[8][4][4][4], num_entries: uN[32] } vs struct 'SlidingWindow' structure: SlidingWindow { data: uN[8][4][4][NUM_ENTRIES], num_entries: uN[32] }: Return type of function body for 'init' did not match the annotated return type.

Looks like we're not resolving the symbolic constant to its final type at the point where we're doing this check.

RobSpringer avatar Sep 29 '22 00:09 RobSpringer