Fix size check when result length exceeds sum of inputs#7
Open
jackscan wants to merge 1 commit intoinspier:masterfrom
Open
Fix size check when result length exceeds sum of inputs#7jackscan wants to merge 1 commit intoinspier:masterfrom
jackscan wants to merge 1 commit intoinspier:masterfrom
Conversation
Contributor
|
Good find. Can you add a test case? |
Author
|
I added doc tests with examples which are supposed to fail. |
Contributor
|
Oh, one more thing. Can you fix the same check in |
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.
Author
|
I've updated the commit to include fix for size check in split_array. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current size check is only catching cases where the inferred result array length is shorter than the sum of the input array lengths.
Longer arrays are accepted and the following code is currently compiling:
let c: [u32; 6] = concat_array!([1, 2, 3], [4, 5]);This results in an array with undefined values.