Closed mvdan closed 2 years ago
This also seems to work:
var elem u8 = arr[in.a >> 6]
I see now that I am supposed to be explicit about ranges when declaring vars:
var b u8[..0x3] = in.a >> 6
var elem u8 = arr[b]
If that's what I should be doing, then please do close this issue. Though I would argue that this should be in an FAQ somewhere; I assumed that Wuffs automatically did this.
Yeah, that will work for now, but longer term, you probably shouldn't need the [..0x3]
range refinement. Currently, after an assignment like x = y
, we automatically add the fact x == y
. In the future, we might also add facts x >= min_possible_y
and x <= max_possible_y
, although specifying exactly how to calculate the min and max values, especially if y is an expression, could be tricky. In your case, after b = in.a >> 6
, that should implicitly assert that b <= 3
, and so the array index arr[b]
is proved in bounds, without needing the [..0x3]
.
But, yeah, in the very short term, adding [..0x3]
will keep you moving.
Awesome, thanks. Should this issue stay open then? I no longer have a blocking issue in the short term, but it would still be nice if this worked automatically.
Let's keep the issue open for now.
However, all of the cases below work:
Funnily enough though, this doesn't work - I presume because the fact gets lost between statements:
Might be related to #5.