authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-08-05 23:17:29-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-08-05 23:17:29-07:00
log47f2463b5c784cb7be9593f56e6b89805dbb8f06
treee08eed656f8d648dcf550dc7244d31a0b3846416
parentc03a04a58942446b48e9294df991a17a3a6f7b48

std.HashMap: fix getPtrAdapted. AstGen: fix fn param iteration

There was a bug in stage2 regarding iteration of function parameter AST. This resulted in a false negative "unused parameter" compile error, which, when fixed, revealed a bug in the std lib HashMap implementation.

2 files changed, 4 insertions(+), 1 deletions(-)

lib/std/hash_map.zig+1-1
...@@ -563,7 +563,7 @@ pub fn HashMap(...@@ -563,7 +563,7 @@ pub fn HashMap(
563 return self.unmanaged.getPtrContext(key, self.ctx);563 return self.unmanaged.getPtrContext(key, self.ctx);
564 }564 }
565 pub fn getPtrAdapted(self: Self, key: anytype, ctx: anytype) ?*V {565 pub fn getPtrAdapted(self: Self, key: anytype, ctx: anytype) ?*V {
566 return self.unmanaged.getPtrAdapted(key, self.ctx);566 return self.unmanaged.getPtrAdapted(key, ctx);
567 }567 }
568568
569 /// Finds the key and value associated with a key in the map569 /// Finds the key and value associated with a key in the map
lib/std/zig/ast.zig+3
...@@ -2198,6 +2198,9 @@ pub const full = struct {...@@ -2198,6 +2198,9 @@ pub const full = struct {
2198 .type_expr = param_type,2198 .type_expr = param_type,
2199 };2199 };
2200 }2200 }
2201 if (token_tags[it.tok_i] == .comma) {
2202 it.tok_i += 1;
2203 }
2201 if (token_tags[it.tok_i] == .r_paren) {2204 if (token_tags[it.tok_i] == .r_paren) {
2202 return null;2205 return null;
2203 }2206 }