google / xls

XLS: Accelerated HW Synthesis
http://google.github.io/xls/
Apache License 2.0
1.2k stars 177 forks source link

DSLX interpreter BadStatusOrAccess when using derived expression in parametric function #1014

Closed proppy closed 1 year ago

proppy commented 1 year ago

The following snippets:

fn z<N:u32, Z:uN[N]={uN[N]:0}>() -> uN[N] {
  Z
}

#[test]
fn z_test() {
  let _= assert_eq(z<u32:32>(), u32:0);
  _
}

Trigger the following BadStatusOrAccess error in the DSLX interpreter:

libc++abi: terminating due to uncaught exception of type absl::lts_20230125::BadStatusOrAccess: Bad StatusOr access: INVALID_ARGUMENT: Expected concrete type dimension to be integral; got: N

Is this intentional?

See https://colab.research.google.com/gist/proppy/c0a011a5e5245987e0c492a3ad6fb396/dslx-issues-playground.ipynb for a notebook that reproduces this issue against the latest version of the xls package:

cdleary commented 1 year ago

I believe coverage guided fuzzing found this one and we've fixed it, now I get:

/tmp/gh_1014.x:8:3-8:4
0006: fn z_test() {
0007:   let _= assert_eq(z<u32:32>(), u32:0);
0008:   _
~~~~~~~~^ ParseError: Wildcard pattern `_` cannot be used as a reference
0009: }