For simple use cases, this is not a problem. For some more complex use cases, now, I must track whether or not the path is originated from a [:0]u8 value.
If you need to care if it is sentinel terminated sometimes it is easier to just make that always the case
As for why this is the case/wasn’t before, I have no idea, I am guessing in the compiler they realised they often need it to be NUL terminated? or just that allocating 1 more byte for a more versatile value isn’t much of a cost.
Advice here was that don’t pass [*:0] into your functions if you already have normal string slices used elsewhere, as you said “I must track whether or not the path is originated from a [:0]u8 value.” sounds like you could have other (allocated) slices too. Depending if your functions want managed or unmanaged slices (if they free them or not), choose either (with dupe or without) way to drop [*:0] as early as possible. Passing extra origin/type of path parameter further is also perf/size/complexity hit later in code.
A data structure in my code might accept three kinds of slices:
[:0]u8 from Dir.realPathFileAlloc
[]u8 from Allocator.dupe
umanaged []8
For the slices of the former two kinds, they have to be freed after being used.
Before Zig 0.16, there were only two kinds (the latter two).
I didn’t find this bug in time when migrate the code from 0.15 to 0.16 (yes, my tests are still not sufficient). The bug was found after the code was migrated to 0.17.
You could use Allocator.dupeSentinel instead of just dupe, so the first two types are aligned, and the code which frees the slices can always free the same kind.