You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
disallow slicing with a sentinel on a multi item pointer (or C pointer)
foo[0..10 :0] this is considered slicing with a sentinel on a multi-item pointer. There's absolutely no reason it shouldn't be allowed.
However slicing a multi-item pointer where end_is_len is true, with a sentinel, I agree doesn't make sense and shouldn't be allowed.
foo[0..10 :0] this is considered slicing with a sentinel on a multi-item pointer. There's absolutely no reason it shouldn't be allowed.
I meant to focus on slicing without an end index. I will clarify the issue description.
Techatrix
changed the title
slicing with a sentinel on a multi item pointer will ignore the sentinel
open slicing with a sentinel on a multi item pointer will ignore the sentinel
Dec 29, 2024
Thanks for the writeup. Let's go with the conservative strategy - disallow it. This choice reflects the goal of minimizing the amount of uncheckable illegal behavior that the language allows.
andrewrk
added
proposal
This issue suggests modifications. If it also has the "accepted" label then it is planned.
accepted
This proposal is planned.
labels
Dec 29, 2024
mlugg
changed the title
open slicing with a sentinel on a multi item pointer will ignore the sentinel
disallow slicing many-pointer with sentinel without end index
Dec 31, 2024
The following code currently compiles without errors:
The sentinel expression is being analyzed but has does nothing.
I can think of two possible ways to resolve this:
ptr[start.. :sentinel]
on a multi item pointer (or C pointer)[*:0]const u8
The problem with the second option is that it is not possible to implement a safety check for it.
Related:
ptr[start..]
#15561s[start..][0..len]
#15519The text was updated successfully, but these errors were encountered: