Commit 94dff4e
committed
Fix size check when composed array is too long
Ensure the union fields of ArrayConcatComposed have matching sizes by
updating the size validations in the macros concat_array and
split_array.
Previously, the size check in concat_arrays were only catching cases
where the inferred result type was shorter than the sum of input array
lengths. It failed to detect longer result arrays, since the size of
Self matches its biggest union field.
For example, this compiled without error:
let c: [u32; 6] = concat_arrays!([1, 2, 3], [4, 5]);
This led to arrays containing undefined values.
The same applied for split_array when the input array is longer than
the sum of the output array lengths. While this did not lead to
undefined values, the exceeding elements would not be dropped.1 parent 79ac0b0 commit 94dff4e
1 file changed
Lines changed: 32 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
12 | 27 | | |
13 | 28 | | |
14 | 29 | | |
| |||
39 | 54 | | |
40 | 55 | | |
41 | 56 | | |
42 | | - | |
| 57 | + | |
43 | 58 | | |
44 | 59 | | |
45 | 60 | | |
| |||
89 | 104 | | |
90 | 105 | | |
91 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
92 | 122 | | |
93 | 123 | | |
94 | 124 | | |
| |||
141 | 171 | | |
142 | 172 | | |
143 | 173 | | |
144 | | - | |
| 174 | + | |
145 | 175 | | |
146 | 176 | | |
147 | 177 | | |
| |||
0 commit comments