diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-03-12 08:35:41 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-03-12 08:35:41 -0400 |
| commit | 5834ff0cc58ffba8e4fe218fcf888d9f9fcf95b2 (patch) | |
| tree | 46eb8f1c9b74a9b9793aa67323661644b959d2cf /test | |
| parent | 1bf2810f338a7bf83455266ef66a535bdc1d4f83 (diff) | |
| download | zig-5834ff0cc58ffba8e4fe218fcf888d9f9fcf95b2.tar.gz zig-5834ff0cc58ffba8e4fe218fcf888d9f9fcf95b2.zip | |
don't memoize comptime fn calls that access comptime mutable state
closes #827
Diffstat (limited to 'test')
| -rw-r--r-- | test/cases/eval.zig | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/cases/eval.zig b/test/cases/eval.zig index e499e1ee1f..a5b41275bb 100644 --- a/test/cases/eval.zig +++ b/test/cases/eval.zig @@ -486,3 +486,20 @@ test "comptime slice of pointer preserves comptime var" { assert(buff[0..][0..][0] == 1); } } + +const SingleFieldStruct = struct { + x: i32, + + fn read_x(self: &const SingleFieldStruct) i32 { + return self.x; + } +}; +test "const ptr to comptime mutable data is not memoized" { + + comptime { + var foo = SingleFieldStruct {.x = 1}; + assert(foo.read_x() == 1); + foo.x = 2; + assert(foo.read_x() == 2); + } +} |
