google / google/xls

`..` range array does not type check correctly

Open
#1,773 0 comments 0 reactions 0 assignees View on GitHub
dslx dslx:type-checking
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

**Describe the bug**
When using `..` to create an array, the array fails type checking even with the "mismatch" reporting exactly the same dimensions.

**To Reproduce**
```
const COUNT = u32:16;

fn foo(bar: u5[COUNT]) -> bool { bar[0] == bar[COUNT - u32:1] }

#[test]
fn foo_test() {
let bar = u5:0..(COUNT as u5);
// let bar = range(Index:0, COUNT as Index);
// let bar = [
// Index:0, Index:1, Index:2, Index:3, Index:4, Index:5, Index:6, Index:7, Index:8, Index:9,
// Index:10, Index:11, Index:12, Index:13, Index:14, Index:15,
// ];
assert_eq(foo(bar), false);
assert_eq(foo(bar), false);
}
```

fails with:

```
1000: assert_eq(foo(bar), false);
~~~~~~~~~~~~~~~~~~~~~~~~^-^ XlsTypeError: Mismatch between parameter and argument types.
Type mismatch:
uN[5][16]
vs uN[5][16]
```

**Expected behavior**
Behaves like creating the array explicitly or using the range builtin. The commented out versions both work.

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.