diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-02-18 13:04:27 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-02-18 19:17:21 -0700 |
| commit | bcb72401d3cf01c190a346af9c9d8eec4a334b45 (patch) | |
| tree | d6af8c82405705c49fd01a8a190df9db5d600248 /src | |
| parent | 22965e6fcbafbcba207a6da8eb493af2cf7ef924 (diff) | |
| download | zig-bcb72401d3cf01c190a346af9c9d8eec4a334b45.tar.gz zig-bcb72401d3cf01c190a346af9c9d8eec4a334b45.zip | |
AstGen: add error for discard of unbounded counter
Diffstat (limited to 'src')
| -rw-r--r-- | src/AstGen.zig | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/AstGen.zig b/src/AstGen.zig index b4fda8e274..866dce02e5 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -6346,8 +6346,9 @@ fn forExpr( const i = @intCast(u32, i_usize); const capture_is_ref = token_tags[capture_token] == .asterisk; const ident_tok = capture_token + @boolToInt(capture_is_ref); + const is_discard = mem.eql(u8, tree.tokenSlice(ident_tok), "_"); - if (mem.eql(u8, tree.tokenSlice(ident_tok), "_") and capture_is_ref) { + if (is_discard and capture_is_ref) { return astgen.failTok(capture_token, "pointer modifier invalid on discard", .{}); } // Skip over the comma, and on to the next capture (or the ending pipe character). @@ -6367,6 +6368,10 @@ fn forExpr( else .none; + if (end_val == .none and is_discard) { + return astgen.failTok(ident_tok, "discard of unbounded counter", .{}); + } + const start_is_zero = nodeIsTriviallyZero(tree, start_node); const range_len = if (end_val == .none or start_is_zero) end_val |
