diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-11-04 17:38:10 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-11-04 17:38:10 -0700 |
| commit | 75efb736ce704fc43bdbe2410989c2b275d855e6 (patch) | |
| tree | 9601aa3c7293a4791f0451a9a99a2319876e2fb0 /src/reduce | |
| parent | 31ad3af956231357ffa2c0fcfaf96a95c2fe1e8b (diff) | |
| download | zig-75efb736ce704fc43bdbe2410989c2b275d855e6.tar.gz zig-75efb736ce704fc43bdbe2410989c2b275d855e6.zip | |
zig reduce: run results through astgen
and use that to fix up usused variable declarations and parameters that
are caused by transformations.
also add a transformation to replace global variable init with
`undefined`.
Diffstat (limited to 'src/reduce')
| -rw-r--r-- | src/reduce/Walk.zig | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/reduce/Walk.zig b/src/reduce/Walk.zig index d62cc4e905..c740ac4f0b 100644 --- a/src/reduce/Walk.zig +++ b/src/reduce/Walk.zig @@ -581,9 +581,12 @@ fn walkGlobalVarDecl(w: *Walk, decl_node: Ast.Node.Index, var_decl: Ast.full.Var try walkExpression(w, var_decl.ast.section_node); } - assert(var_decl.ast.init_node != 0); - - return walkExpression(w, var_decl.ast.init_node); + if (var_decl.ast.init_node != 0) { + if (!isUndefinedIdent(w.ast, var_decl.ast.init_node)) { + try w.transformations.append(.{ .replace_with_undef = var_decl.ast.init_node }); + } + try walkExpression(w, var_decl.ast.init_node); + } } fn walkLocalVarDecl(w: *Walk, var_decl: Ast.full.VarDecl) Error!void { |
