aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-03-12 01:21:10 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-03-12 01:21:10 -0400
commit1bf2810f338a7bf83455266ef66a535bdc1d4f83 (patch)
treec7abc8f4a0a6b0fed5621051ce2a02d3ec9a0835 /test
parent49c3922037ef0b913466e707d85a4e085f6e9716 (diff)
downloadzig-1bf2810f338a7bf83455266ef66a535bdc1d4f83.tar.gz
zig-1bf2810f338a7bf83455266ef66a535bdc1d4f83.zip
fix comptime slicing not preserving comptime mutability
* fix comptime slice of slice not preserving mutatibility of the comptime data * fix comptime slice of pointer not preserving mutability of the comptime data closes #826
Diffstat (limited to 'test')
-rw-r--r--test/cases/eval.zig17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/cases/eval.zig b/test/cases/eval.zig
index ef6fa73ce3..e499e1ee1f 100644
--- a/test/cases/eval.zig
+++ b/test/cases/eval.zig
@@ -469,3 +469,20 @@ fn doesAlotT(comptime T: type, value: usize) T {
test "@setEvalBranchQuota at same scope as generic function call" {
assert(doesAlotT(u32, 2) == 2);
}
+
+test "comptime slice of slice preserves comptime var" {
+ comptime {
+ var buff: [10]u8 = undefined;
+ buff[0..][0..][0] = 1;
+ assert(buff[0..][0..][0] == 1);
+ }
+}
+
+test "comptime slice of pointer preserves comptime var" {
+ comptime {
+ var buff: [10]u8 = undefined;
+ var a = &buff[0];
+ a[0..1][0] = 1;
+ assert(buff[0..][0..][0] == 1);
+ }
+}