You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An assignment to a comptime variable is predicated by a run-time value, but the compiler doesn't emit an error.
Instead, it uses "program" order and performs assignments on all branches. In particular, flipping the branch
condition and inverting the branch blocks should produce an equivalent program, but it doesn't.
(This could be me misinterpreting the comptime documentation)
// first print => error: writing to comptime variable on a path that depends on a runtime value
/// second print => error: writing to comptime variable on a path that depends on a runtime value
foo(-1) = 2!
foo(1) = 1!
Tags searched before filing this issue
comptime variable branch
Tested with Zig versions:
trunk (version available at the time of writing on Godbolt)
.7
.6
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
What
An assignment to a comptime variable is predicated by a run-time value, but the compiler doesn't emit an error.
Instead, it uses "program" order and performs assignments on all branches. In particular, flipping the branch
condition and inverting the branch blocks should produce an equivalent program, but it doesn't.
(This could be me misinterpreting the comptime documentation)
Code that reproduces the issue
Godbolt link
Produced output
Expected output
Tags searched before filing this issue
comptime variable branch
Tested with Zig versions:
The text was updated successfully, but these errors were encountered: