DSLX document signed one bit number corner case
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 283
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 135
Description
Our variable bitwidth types are the cartesian product of (signed, unsigned) x (1 bit, 2 bits, 3 bits, ...). `bool` is an alias for u1, where `true` keyword without a type implicitly is the same as `u1:1` and `false` keyword without a type implicitly is the same as `u1:0`. Explicitly writing `u1:true` and `u1:false` have no effect, they're redundantly indicating the type context is unsigned. However, users can currently also write `s1:true` and `s1:false` (providing the boolean value with an explicitly signed type context). With a one bit signed number there is only sign, no effective magnitude available, so these are equivalent to `s1:-1` (note that -1 is the "all bits set" value) and `s1:0` (note that 0 is the "no bits set" value).
This issue track that we should either outlaw boolean keywords with a signed type context or document how it maps, maybe just as described above or maybe there are more interesting angles to point out / consider.
Contributor guide
Assessment
This issue has not been assessed yet.