From d227f76afbacb619152ffd943cf3018e62e00adc Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 30 Mar 2022 11:52:10 -0700 Subject: [PATCH] std.zig.Ast: fix escaped capture of by-value parameters --- lib/std/zig/Ast.zig | 6 +++--- src/AstGen.zig | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/std/zig/Ast.zig b/lib/std/zig/Ast.zig index b485f915f0..230eff84c0 100644 --- a/lib/std/zig/Ast.zig +++ b/lib/std/zig/Ast.zig @@ -2354,10 +2354,10 @@ pub const full = struct { } }; - pub fn iterate(fn_proto: FnProto, tree: Ast) Iterator { + pub fn iterate(fn_proto: *const FnProto, tree: *const Ast) Iterator { return .{ - .tree = &tree, - .fn_proto = &fn_proto, + .tree = tree, + .fn_proto = fn_proto, .param_i = 0, .tok_i = fn_proto.lparen + 1, .tok_flag = true, diff --git a/src/AstGen.zig b/src/AstGen.zig index ed6c9f86ce..1e4865bd97 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -1122,7 +1122,7 @@ fn fnProtoExpr( const is_var_args = is_var_args: { var param_type_i: usize = 0; - var it = fn_proto.iterate(tree.*); + var it = fn_proto.iterate(tree); while (it.next()) |param| : (param_type_i += 1) { const is_comptime = if (param.comptime_noalias) |token| token_tags[token] == .keyword_comptime @@ -3377,7 +3377,7 @@ fn fnDecl( var params_scope = &fn_gz.base; const is_var_args = is_var_args: { var param_type_i: usize = 0; - var it = fn_proto.iterate(tree.*); + var it = fn_proto.iterate(tree); while (it.next()) |param| : (param_type_i += 1) { const is_comptime = if (param.comptime_noalias) |token| token_tags[token] == .keyword_comptime