| author | |
| committer | |
| log | 6e66f7f2b80b0c12b1a2fc1203bc780dbf89294c |
| tree | d08643e326ce5373c977d8276519a052fb5ba26d |
| parent | 7eeb21f3a65ceabd2fce766c9a56bee68b92b380 |
2 files changed, 6 insertions(+), 4 deletions(-)
lib/std/zig/AstGen.zig+3-3| ... | @@ -3489,10 +3489,10 @@ fn assignDestructureMaybeDecls( | ... | @@ -3489,10 +3489,10 @@ fn assignDestructureMaybeDecls( |
| 3489 | // Typed alloc | 3489 | // Typed alloc |
| 3490 | const type_inst = try typeExpr(gz, scope, type_node); | 3490 | const type_inst = try typeExpr(gz, scope, type_node); |
| 3491 | const ptr = if (align_inst == .none) ptr: { | 3491 | const ptr = if (align_inst == .none) ptr: { |
| 3492 | const tag: Zir.Inst.Tag = if (is_const) | 3492 | const tag: Zir.Inst.Tag = if (this_variable_comptime) |
| 3493 | .alloc | ||
| 3494 | else if (this_variable_comptime) | ||
| 3495 | .alloc_comptime_mut | 3493 | .alloc_comptime_mut |
| 3494 | else if (is_const) | ||
| 3495 | .alloc | ||
| 3496 | else | 3496 | else |
| 3497 | .alloc_mut; | 3497 | .alloc_mut; |
| 3498 | break :ptr try gz.addUnNode(tag, type_inst, node); | 3498 | break :ptr try gz.addUnNode(tag, type_inst, node); |
test/behavior/destructure.zig+3-1| ... | @@ -27,14 +27,16 @@ test "destructure with comptime syntax" { | ... | @@ -27,14 +27,16 @@ test "destructure with comptime syntax" { |
| 27 | fn doTheTest() !void { | 27 | fn doTheTest() !void { |
| 28 | { | 28 | { |
| 29 | comptime var x: f32 = undefined; | 29 | comptime var x: f32 = undefined; |
| 30 | comptime x, const y, var z = .{ 0.5, 123, 456 }; // z is a comptime var | 30 | comptime x, const y, var z, const w: u32 = .{ 0.5, 123, 456, 789 }; // z is a comptime var |
| 31 | _ = &z; | 31 | _ = &z; |
| 32 | 32 | ||
| 33 | comptime assert(@TypeOf(y) == comptime_int); | 33 | comptime assert(@TypeOf(y) == comptime_int); |
| 34 | comptime assert(@TypeOf(z) == comptime_int); | 34 | comptime assert(@TypeOf(z) == comptime_int); |
| 35 | comptime assert(@TypeOf(w) == u32); | ||
| 35 | comptime assert(x == 0.5); | 36 | comptime assert(x == 0.5); |
| 36 | comptime assert(y == 123); | 37 | comptime assert(y == 123); |
| 37 | comptime assert(z == 456); | 38 | comptime assert(z == 456); |
| 39 | comptime assert(w == 789); | ||
| 38 | } | 40 | } |
| 39 | { | 41 | { |
| 40 | var w: u8, var x: u8 = .{ 1, 2 }; | 42 | var w: u8, var x: u8 = .{ 1, 2 }; |