xls icon indicating copy to clipboard operation
xls copied to clipboard

Parametric value not usable in slice expression

Open dkillebrew-g opened this issue 5 years ago • 2 comments

I understand "constexpr" is a work in progress. Just letting you know this case is useful, but not parsing yet:

fn pad<X : u32, R : u32, DIFF : u32 = R-X>(xs : u32[X]) -> u32[R] {
  xs ++ u32[DIFF] : [0, ...]
  if R >= X
  else xs[:R]
}

So you can use it as a test case when you're done with constexpr work.

Currently, the error is

* 0167:   else xs[:R]
        ~~~~~~~~~^--^ ParseError: blah.x:167:10-167:14 Only constant numbers are currently allowed in slice expressions.

dkillebrew-g avatar Nov 20 '20 23:11 dkillebrew-g

Just a note that #207 is very related, both all about constexpr evaluation.

cdleary avatar Jan 22 '21 22:01 cdleary

I think I failed to realize on my first reading this is actually an array slice, not a bit slice. So blocked on https://github.com/google/xls/issues/312 and https://github.com/google/xls/issues/126

cdleary avatar Mar 08 '21 03:03 cdleary