const std = @import("std");
pub fn main() void {
var u = &User{ .id = 2 };
u.id = 54;
}
const User = struct { id: i32 };
The above code gives me the following error, the variable is declared using the var
modifier yet it says cannot assign to constant.
main.zig:5:6: error: cannot assign to constant
u.id = 54;
~^~~
referenced by:
callMain: /opt/homebrew/Cellar/zig/0.12.0/lib/zig/std/start.zig:501:17
callMainWithArgs: /opt/homebrew/Cellar/zig/0.12.0/lib/zig/std/start.zig:469:12
remaining reference traces hidden; use '-freference-trace' to see all reference traces