New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorrect comptime memoization #827

andrewrk opened this Issue Mar 12, 2018 · 0 comments


None yet
1 participant

andrewrk commented Mar 12, 2018

const assert = @import("std").debug.assert;

const Foo = struct {
    x: i32,

    fn read_x(self: &const Foo) i32 {
        return self.x;

comptime {
    var foo = Foo {.x = 1};
    assert(foo.read_x() == 1);
    foo.x = 2;
    assert(foo.read_x() == 2);
/home/andy/dev/zig/build/lib/zig/std/debug/index.zig:84:13: error: encountered @panic at compile-time
            @panic("assertion failure");
/home/andy/dev/zig/build/test.zig:15:11: note: called from here
    assert(foo.read_x() == 2);
/home/andy/dev/zig/build/test.zig:11:10: note: called from here
comptime {

@andrewrk andrewrk added the bug label Mar 12, 2018

@andrewrk andrewrk added this to the 0.2.0 milestone Mar 12, 2018

@andrewrk andrewrk closed this in 5834ff0 Mar 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment