Seemingly valid bit vector indexing yields parse errors
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 283
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 135
Description
Code is below. Errors and the problematic code are in the comments
```rust
# my_lib
pub const W = s32:16;
pub const Z = s32:24;
```
```rust
import my_lib;
pub const A = s32:16;
pub const B = s32:24;
fn foo(x: u32) -> () {
// 0013: let a = x[my_lib::W : s32:24];
// ~~~~~~~~~~~~~~~~~^------------------^ TypeInferenceError: uN[32] Value to index is not an array.
// let a = x[my_lib::W : s32:24];
// 0017: let b = x[my_lib::W : my_lib::Z];
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ ParseError: Old-style cast only permitted for constant arrays/tuples and literal numbers.
// let b = x[my_lib::W : my_lib::Z];
// OK.
let c = x[A:my_lib::Z];
// OK.
let d = x[A:B];
()
}
```
Contributor guide
Assessment
This issue has not been assessed yet.