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

Bug in comptime function memoization? #639

Closed
thejoshwolfe opened this Issue Dec 2, 2017 · 0 comments

Comments

Projects
None yet
2 participants
@thejoshwolfe
Member

thejoshwolfe commented Dec 2, 2017

I haven't pinned down exactly what's going wrong here, but I think it's a bug in logic that the comptime evaluator uses to determine if a function call can be skipped because it's identical to the last time we called the function.

On commit 67b8b00 :

~/dev/zig/build$ ./zig test ../std/sort.zig
/home/josh/dev/zig/std/debug.zig:55:13: error: unable to evaluate constant expression
            @panic("assertion failure")
            ^
/home/josh/dev/zig/std/sort.zig:118:19: note: called from here
            assert(item.value == expected[i].value);
                  ^
/home/josh/dev/zig/std/sort.zig:76:28: note: called from here
    comptime testStableSort();
                           ^

By throwing @compileLog()s all over the place, my best guess is that sort_stable() is only really getting called for the first case, not the second.

@thejoshwolfe thejoshwolfe added the bug label Dec 2, 2017

@thejoshwolfe thejoshwolfe reopened this Dec 2, 2017

@andrewrk andrewrk added this to the 0.2.0 milestone Dec 3, 2017

@andrewrk andrewrk closed this in 6db9be8 Mar 9, 2018

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