diff --git a/lib/std/zig/AstGen.zig b/lib/std/zig/AstGen.zig index c0860b71f61109a5b8dce360c1dea585d31d2b37..ef299a3fe7e255a9020b1578d1c684a35449f46c 100644 --- a/lib/std/zig/AstGen.zig +++ b/lib/std/zig/AstGen.zig @@ -3489,10 +3489,10 @@ fn assignDestructureMaybeDecls( // Typed alloc const type_inst = try typeExpr(gz, scope, type_node); const ptr = if (align_inst == .none) ptr: { - const tag: Zir.Inst.Tag = if (is_const) + const tag: Zir.Inst.Tag = if (this_variable_comptime) + .alloc_comptime_mut + else if (is_const) .alloc - else if (this_variable_comptime) - .alloc_comptime_mut else .alloc_mut; break :ptr try gz.addUnNode(tag, type_inst, node); diff --git a/test/behavior/destructure.zig b/test/behavior/destructure.zig index 43ddbb7a4de088d57f1a4f9b14f795369037fcc3..a14c05536d7ebe4db08718f15850f1ba233fd4bb 100644 --- a/test/behavior/destructure.zig +++ b/test/behavior/destructure.zig @@ -27,14 +27,16 @@ test "destructure with comptime syntax" { fn doTheTest() !void { { comptime var x: f32 = undefined; - comptime x, const y, var z = .{ 0.5, 123, 456 }; // z is a comptime var + comptime x, const y, var z, const w: u32 = .{ 0.5, 123, 456, 789 }; // z is a comptime var _ = &z; comptime assert(@TypeOf(y) == comptime_int); comptime assert(@TypeOf(z) == comptime_int); + comptime assert(@TypeOf(w) == u32); comptime assert(x == 0.5); comptime assert(y == 123); comptime assert(z == 456); + comptime assert(w == 789); } { var w: u8, var x: u8 = .{ 1, 2 };