Sema: support pointer subtraction
This commit is contained in:
@@ -11,6 +11,9 @@ test "pointer arithmetic with many-item pointer" {
|
||||
// slicing a many-item pointer without an end is equivalent to
|
||||
// pointer arithmetic: `ptr[start..] == ptr + start`
|
||||
try expect(ptr[1..] == ptr + 1);
|
||||
|
||||
// subtraction between any two pointers except slices based on element size is supported
|
||||
try expect(&ptr[1] - &ptr[0] == 1);
|
||||
}
|
||||
|
||||
test "pointer arithmetic with slices" {
|
||||
|
||||
Reference in New Issue
Block a user