zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit cf7b0a0493f23ccedb071fd297f98a3d27336e39 (tree)
parent bbe6c341915c7cd26e0928198ca7324c49bbe2aa
Author: Motiejus Jakštys <motiejus@jakstys.lt>
Date:   Mon, 16 Feb 2026 12:28:40 +0000

astgen: fix gzUnstack/gzAppendInstruction ordering in comptime destructure assignments

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Diffstat:
Mstage0/astgen.c | 8++++++--
Mstage0/astgen_test.zig | 2+-
2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/stage0/astgen.c b/stage0/astgen.c @@ -11584,8 +11584,10 @@ static void assignDestructure(GenZir* gz, Scope* scope, uint32_t node) { ZIR_REF_VOID_VALUE, AST_NODE_OFFSET_NONE); setBlockComptimeBody(ag, inner_gz, comptime_block_inst, COMPTIME_REASON_COMPTIME_KEYWORD); - gzAppendInstruction(gz, comptime_block_inst); + // Unstack inner_gz before appending to gz so that the + // block_comptime instruction lands in gz's tracking range. gzUnstack(inner_gz); + gzAppendInstruction(gz, comptime_block_inst); } free(rl_components); } @@ -11763,8 +11765,10 @@ static Scope* assignDestructureMaybeDecls(GenZir* gz, Scope* scope, ZIR_REF_VOID_VALUE, AST_NODE_OFFSET_NONE); setBlockComptimeBody(ag, inner_gz, comptime_block_inst, COMPTIME_REASON_COMPTIME_KEYWORD); - gzAppendInstruction(gz, comptime_block_inst); + // Unstack inner_gz before appending to gz so that the + // block_comptime instruction lands in gz's tracking range. gzUnstack(inner_gz); + gzAppendInstruction(gz, comptime_block_inst); } // Third pass: create scopes for declared variables (AstGen.zig:3664-3729). diff --git a/stage0/astgen_test.zig b/stage0/astgen_test.zig @@ -1231,7 +1231,7 @@ const corpus_files = .{ "../test/behavior/decl_literals.zig", "../test/behavior/decltest.zig", "../test/behavior/defer.zig", - //"../test/behavior/destructure.zig", + "../test/behavior/destructure.zig", "../test/behavior/duplicated_test_names.zig", "../test/behavior/empty_union.zig", "../test/behavior/export_builtin.zig",