| 1 | const value: u8 = 1; |
| 2 | const ptr = &value; |
| 3 | |
| 4 | comptime { |
| 5 | _ = ptr[0..]; |
| 6 | } |
| 7 | |
| 8 | comptime { |
| 9 | _ = ptr[1..2]; |
| 10 | } |
| 11 | |
| 12 | comptime { |
| 13 | _ = ptr[0..2]; |
| 14 | } |
| 15 | |
| 16 | comptime { |
| 17 | _ = ptr[2..2]; |
| 18 | } |
| 19 | |
| 20 | export fn entry1() void { |
| 21 | var start: usize = 0; |
| 22 | _ = &start; |
| 23 | _ = ptr[start..2]; |
| 24 | } |
| 25 | |
| 26 | export fn entry2() void { |
| 27 | var end: usize = 0; |
| 28 | _ = &end; |
| 29 | _ = ptr[0..end]; |
| 30 | } |
| 31 | |
| 32 | // error |
| 33 | // |
| 34 | // :5:12: error: slice of single-item pointer must be bounded |
| 35 | // :9:13: error: slice of single-item pointer must have bounds [0..0], [0..1], or [1..1] |
| 36 | // :9:13: note: expected '0', found '1' |
| 37 | // :13:16: error: slice of single-item pointer must have bounds [0..0], [0..1], or [1..1] |
| 38 | // :13:16: note: expected '1', found '2' |
| 39 | // :17:16: error: end index 2 out of bounds for slice of single-item pointer |
| 40 | // :23:13: error: unable to resolve comptime value |
| 41 | // :23:13: note: slice of single-item pointer must have comptime-known bounds |
| 42 | // :29:16: error: unable to resolve comptime value |
| 43 | // :29:16: note: slice of single-item pointer must have comptime-known bounds |