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
bugObserved behavior contradicts documented or intended behaviorenhancementSolving this issue will likely involve adding new logic or components to the codebase.frontendTokenization, parsing, AstGen, Sema, and Liveness.
$ stage4/bin/zig test test.zig
test.zig:6:13: error: type '*test.test.memset a tuple__struct_1040' does not support indexing
@memset(&t, [_]i32{ 56, 78 });
^~
test.zig:6:13: note: for loop operand must be an array, slice, tuple, or vector
test.zig:14:13: error: type '*test.test.memcpy a tuple__struct_1041' does not support indexing
@memset(&t1, &t2);
^~~
test.zig:14:13: note: for loop operand must be an array, slice, tuple, or vector
Same as the reason that @memcpy supports both src and dest being an array, even though it is equivalent to dest.* = src.*. The reason being language consistency.
Reacted by InKryption, Andrey Kirpach and Andrew Dunbar
To implement this reasonably, as well as for more general consistency between arrays and tuples, Zig should define homogeneous tuples (by which I mean tuples whose fields all have the same type) as having the same memory layout as arrays (i.e. fields laid out contiguously in memory with no extra padding). Is this something which the (theoretical) spec already guarantees? (As far as I know the implementation does, although I haven't checked.)
bugObserved behavior contradicts documented or intended behaviorenhancementSolving this issue will likely involve adding new logic or components to the codebase.frontendTokenization, parsing, AstGen, Sema, and Liveness.
Activity
InKryption commentedon Apr 26, 2023
What's the use case behind this? Why would one opt for the builtins when we can already do
foo = barandfoo = .{ 12, 14 },bar = .{0} ** bar.len?andrewrk commentedon Apr 26, 2023
Same as the reason that
@memcpysupports both src and dest being an array, even though it is equivalent todest.* = src.*. The reason being language consistency.mlugg commentedon Aug 27, 2023
To implement this reasonably, as well as for more general consistency between arrays and tuples, Zig should define homogeneous tuples (by which I mean tuples whose fields all have the same type) as having the same memory layout as arrays (i.e. fields laid out contiguously in memory with no extra padding). Is this something which the (theoretical) spec already guarantees? (As far as I know the implementation does, although I haven't checked.)
mlugg commentedon Feb 7, 2025
I think this is no longer intended behavior given our recent restriction of the definition of
@memcpy.