Add bound check for list and range (#185) #255

Merged
sb10q merged 1 commits from bound_check into master 2024-08-17 17:37:19 +08:00
1 changed files with 1 additions and 1 deletions
Showing only changes of commit 86ce513cb5 - Show all commits

View File

@ -229,7 +229,7 @@ def list_slice_assignment():
bl5[3:-5] = [] bl5[3:-5] = []
output_int32_list([int32(b) for b in bl5]) output_int32_list([int32(b) for b in bl5])
bl6 = bl[:] bl6 = bl[:]
bl6[3:-5] = [True, False, False] bl6[3:-5] = [True, False]
pca006132 marked this conversation as resolved
Review

what is this?

what is this?
Review

This is the 'fix broken test' commit. This test should not pass because the length of bl6 is 10, so bl[3:-5] is bl[3,5], which has length 2, so this test is actually extending the list, which is not supported.

Previously this test happened to accidentally pass because we do not have the check on the list slice assignment yet, and the value of the assignment accidentally make the test pass. In fact, just by changing the bl6[3:-5] = [True, False, False] to bl6[3:-5] = [True, False, True] or something else, this test will fail before this PR.

This is the 'fix broken test' commit. This test should not pass because the length of `bl6` is 10, so `bl[3:-5]` is `bl[3,5]`, which has length 2, so this test is actually extending the list, which is not supported. Previously this test happened to accidentally pass because we do not have the check on the list slice assignment yet, and the value of the assignment accidentally make the test pass. In fact, just by changing the `bl6[3:-5] = [True, False, False]` to `bl6[3:-5] = [True, False, True]` or something else, this test will fail before this PR.
output_int32_list([int32(b) for b in bl6]) output_int32_list([int32(b) for b in bl6])
bl7 = bl[:] bl7 = bl[:]
bl7[:-2] = [False] bl7[:-2] = [False]