diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-04-28 17:45:33 +0300 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-04-28 17:45:33 +0300 |
| commit | 095d51164f53ee7f23aae9dbe08270eacf61d97b (patch) | |
| tree | 6b281707a59612dce18c9584b413635efd3874eb /test/behavior/slice.zig | |
| parent | 6f4343b61afe36a709e713735947561a2b76bce8 (diff) | |
| download | zig-095d51164f53ee7f23aae9dbe08270eacf61d97b.tar.gz zig-095d51164f53ee7f23aae9dbe08270eacf61d97b.zip | |
Sema: fix slice field modification at comptime
Diffstat (limited to 'test/behavior/slice.zig')
| -rw-r--r-- | test/behavior/slice.zig | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/behavior/slice.zig b/test/behavior/slice.zig index 09d15e3ac5..18c769f27c 100644 --- a/test/behavior/slice.zig +++ b/test/behavior/slice.zig @@ -682,3 +682,14 @@ test "slicing slice with sentinel as end index" { try S.do(); comptime try S.do(); } + +test "slice len modification at comptime" { + comptime { + var buf: [10]u8 = .{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + var items: []u8 = buf[0..0]; + items.len += 2; + try expect(items.len == 2); + try expect(items[0] == 0); + try expect(items[1] == 1); + } +} |
