google / google/xls

DSLX dynamic width-slice referential transparency violation in interpreter impl

Open
#291 1 comment 0 reactions 0 assignees View on GitHub
bug dslx good first issue
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

Something I stumbled across is we currently pass type checking but fail in the interpreter for an expression like the following:

```dslx
let x: u7 = ...;
let i = u26:-1;
let sliced: u32 = x[i+:u2];
```

```dslx
let x: u7 = ...;
let sliced: u32 = x[u26:-1+:u2];
```

The interpreter I believe does not blow up on the former but blows up on the latter, because its implementation is taking a different path when the start is a literal number, and you get something like "u26:-1 does not fit in 7 bits". I think this cropped up in the first place because we wanted to let people avoid annotating the width of the start, and instead be able to infer it from the subject being sliced.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.