Sema: support pointer subtraction

This commit is contained in:
Wooster
2024-07-16 03:18:38 +09:00
committed by GitHub
parent 89942ebd03
commit 888708ec8a
7 changed files with 230 additions and 46 deletions

View File

@@ -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" {