diff options
| author | Jacob G-W <jacoblevgw@gmail.com> | 2021-07-14 18:17:55 -0400 |
|---|---|---|
| committer | Jacob G-W <jacoblevgw@gmail.com> | 2021-07-14 18:17:55 -0400 |
| commit | 1799455e0587644c98cdba67bd10a59a2d45b116 (patch) | |
| tree | 6539087c26b1984a0fc3ed391efdb1955d79bf01 /src | |
| parent | 759d1d9aeffbe1c5eaf7d5675b6d1c165757cdf1 (diff) | |
| download | zig-1799455e0587644c98cdba67bd10a59a2d45b116.tar.gz zig-1799455e0587644c98cdba67bd10a59a2d45b116.zip | |
astgen: errors for shadowing in if captures
Diffstat (limited to 'src')
| -rw-r--r-- | src/AstGen.zig | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/AstGen.zig b/src/AstGen.zig index e30f3a272c..019e73c983 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -5008,6 +5008,7 @@ fn ifExpr( const token_name_str = tree.tokenSlice(token_name_index); if (mem.eql(u8, "_", token_name_str)) break :s &then_scope.base; + try astgen.detectLocalShadowing(&then_scope.base, ident_name, token_name_index); payload_val_scope = .{ .parent = &then_scope.base, .gen_zir = &then_scope, @@ -5030,6 +5031,7 @@ fn ifExpr( break :s &then_scope.base; const payload_inst = try then_scope.addUnNode(tag, cond.inst, node); const ident_name = try astgen.identAsString(ident_token); + try astgen.detectLocalShadowing(&then_scope.base, ident_name, ident_token); payload_val_scope = .{ .parent = &then_scope.base, .gen_zir = &then_scope, @@ -5071,6 +5073,7 @@ fn ifExpr( const error_token_str = tree.tokenSlice(error_token); if (mem.eql(u8, "_", error_token_str)) break :s &else_scope.base; + try astgen.detectLocalShadowing(&else_scope.base, ident_name, error_token); payload_val_scope = .{ .parent = &else_scope.base, .gen_zir = &else_scope, |
