diff options
| author | Daniel Hooper <danielchasehooper@gmail.com> | 2022-03-20 06:55:04 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-20 12:55:04 +0200 |
| commit | 911c839e97194eb270389b03d4d364659c46a5ac (patch) | |
| tree | 1b6579a3b1b472c26d8d3879477b7039512da8ea /src/AstGen.zig | |
| parent | 0576086395774389a9f38d960f9ed5102a813bdb (diff) | |
| download | zig-911c839e97194eb270389b03d4d364659c46a5ac.tar.gz zig-911c839e97194eb270389b03d4d364659c46a5ac.zip | |
add error when binary ops don't have matching whitespace on both sides
This change also moves the warning about "&&" from the AstGen into the parser so that the "&&" warning can supersede the whitespace warning.
Diffstat (limited to 'src/AstGen.zig')
| -rw-r--r-- | src/AstGen.zig | 19 |
1 files changed, 1 insertions, 18 deletions
diff --git a/src/AstGen.zig b/src/AstGen.zig index 1fe524572b..4221f0cd14 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -669,24 +669,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: Ast.Node.Index) InnerEr .mod => return simpleBinOp(gz, scope, rl, node, .mod_rem), .shl_sat => return simpleBinOp(gz, scope, rl, node, .shl_sat), - .bit_and => { - const current_ampersand_token = main_tokens[node]; - if (token_tags[current_ampersand_token + 1] == .ampersand) { - const token_starts = tree.tokens.items(.start); - const current_token_offset = token_starts[current_ampersand_token]; - const next_token_offset = token_starts[current_ampersand_token + 1]; - if (current_token_offset + 1 == next_token_offset) { - return astgen.failTok( - current_ampersand_token, - "`&&` is invalid; note that `and` is boolean AND", - .{}, - ); - } - } - - return simpleBinOp(gz, scope, rl, node, .bit_and); - }, - + .bit_and => return simpleBinOp(gz, scope, rl, node, .bit_and), .bit_or => return simpleBinOp(gz, scope, rl, node, .bit_or), .bit_xor => return simpleBinOp(gz, scope, rl, node, .xor), .bang_equal => return simpleBinOp(gz, scope, rl, node, .cmp_neq), |
