-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DSLX: bug: internal error when using derived parametric #992
Comments
@proppy I haven't encountered Sample 1 yet when working on RLE/DBE. Sample 2 affected me when writing DBE code, but thankfully we have a workaround for this (namely, to use a derived parametric in the proc which instantiates the struct), so it's not a blocker. |
I recently got similar issue when trying to create parametrized struct with derived parametrics, however I got different error message (possibly because there were changes in code since this one was opened). Sample code: struct StructFoo<A: u32, B: u32 = {u32:32}, C:u32 = {B / u32:2}> {
a: uN[A],
b: uN[B],
c: uN[C],
}
fn FuncFoo<A: u32, B: u32 = {u32:32}, C:u32 = {B / u32:2}>() -> () {
trace_fmt!("func A {}", A);
trace_fmt!("func B {}", B);
trace_fmt!("func C {}", C);
}
fn print_struct_widths<A: u32, B: u32, C: u32>(s: StructFoo<A, B, C>) -> () {
trace_fmt!("struct A {}", A);
trace_fmt!("struct B {}", B);
trace_fmt!("struct C {}", C);
}
#[test]
fn Foo() {
FuncFoo<u32:32, u32:16>();
print_struct_widths(zero!<StructFoo<u32:32, u32:16>>());
FuncFoo<u32:32>();
print_struct_widths(zero!<StructFoo<u32:32>>());
FuncFoo<u32:32, u32:16, u32:16>();
print_struct_widths(zero!<StructFoo<u32:32, u32:16, u32:16>>());
} Error after building dslx target:
I expect the struct's parameters to behave similarly to function's parameters, so I added there the parametric function to compare the results. Also I noticed that when there is no default value set for parametric that is used to derive another parametric, then the error is returned. For example, if we change fn FuncFoo<A: u32, B: u32, C:u32 = {B / u32:2}>() -> () {
trace_fmt!("func A {}", A);
trace_fmt!("func B {}", B);
trace_fmt!("func C {}", C);
} then we get
XLS commit hash: |
#992 PiperOrigin-RevId: 673013387
For structs, these only need to be set once the struct is actually used. There's a separate check for that. #992 PiperOrigin-RevId: 673378184
I wasn't able to exactly reproduce the original issue here, but investigating this comment exposed a couple of bugs related to:
The second item should be fixed by 6cf8a0d. For the first item, I opened #1597 as a longer-term project. If there are specific operations/expressions that are missing and blocking work, please let us know and we can prioritize those. |
Consider following parametric structure:
Sample 1
This code generates following internal error:
Sample 2
Contrary to sample 1, this results in the following type error:
-----
The first one is surely a bug as it raises internal error; the second one I am not sure, but as a user I would prefer it to just work, since I think the code contains enough information for the interpreter to resolve all the parametrics (unless I'm missing something!)
The text was updated successfully, but these errors were encountered: