Move diagnostic kind name to the end of the diagnostic. (#4437)

Also surround it in square brackets rather than parentheses. This
matches the format used by Clang and GCC, and means diagnostics will
still match the `file:line:col: error: ` pattern used by some IDE tools.

Before:
```console
fail_builtins.carbon:11:11: error(AliasRequiresNameRef): alias initializer must be a name reference
```

After:
```console
fail_builtins.carbon:11:11: error: alias initializer must be a name reference [AliasRequiresNameRef]
```

Also tighten up test regex to only match on `STDERR` lines that list a
file name.
This commit is contained in:
Richard Smith
2024-10-23 16:56:23 +00:00
committed by GitHub
parent f206072216
commit 2e63da1a40
528 changed files with 1929 additions and 1928 deletions
@@ -13,7 +13,7 @@ fn F() {
var b: i32;
// TODO: Produce a custom diagnostic for this.
// CHECK:STDERR: fail_chained_assign.carbon:[[@LINE+3]]:9: error(StatementOperatorAsSubExpr): operator `=` can only be used as a complete statement
// CHECK:STDERR: fail_chained_assign.carbon:[[@LINE+3]]:9: error: operator `=` can only be used as a complete statement [StatementOperatorAsSubExpr]
// CHECK:STDERR: a = b = 1;
// CHECK:STDERR: ^
a = b = 1;
@@ -10,7 +10,7 @@
// TODO: We could figure out that this first Failed example is infix
// with one-token lookahead.
// CHECK:STDERR: fail_infix_uneven_space_after.carbon:[[@LINE+3]]:16: error(ExpectedDeclSemi): `var` declarations must end with a `;`
// CHECK:STDERR: fail_infix_uneven_space_after.carbon:[[@LINE+3]]:16: error: `var` declarations must end with a `;` [ExpectedDeclSemi]
// CHECK:STDERR: var n: i8 = n* n;
// CHECK:STDERR: ^
var n: i8 = n* n;
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/operators/fail_infix_uneven_space_before.carbon
// CHECK:STDERR: fail_infix_uneven_space_before.carbon:[[@LINE+3]]:15: error(BinaryOperatorRequiresWhitespace): whitespace missing after binary operator
// CHECK:STDERR: fail_infix_uneven_space_before.carbon:[[@LINE+3]]:15: error: whitespace missing after binary operator [BinaryOperatorRequiresWhitespace]
// CHECK:STDERR: var n: i8 = n *n;
// CHECK:STDERR: ^
var n: i8 = n *n;
@@ -8,21 +8,21 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/operators/fail_invalid_infix.carbon
// CHECK:STDERR: fail_invalid_infix.carbon:[[@LINE+4]]:19: error(ExpectedExpr): expected expression
// CHECK:STDERR: fail_invalid_infix.carbon:[[@LINE+4]]:19: error: expected expression [ExpectedExpr]
// CHECK:STDERR: var a: i32 = n == ;
// CHECK:STDERR: ^
// CHECK:STDERR:
var a: i32 = n == ;
// CHECK:STDERR: fail_invalid_infix.carbon:[[@LINE+4]]:14: error(ExpectedExpr): expected expression
// CHECK:STDERR: fail_invalid_infix.carbon:[[@LINE+4]]:14: error: expected expression [ExpectedExpr]
// CHECK:STDERR: var b: i32 = == n;
// CHECK:STDERR: ^~
// CHECK:STDERR:
var b: i32 = == n;
// CHECK:STDERR: fail_invalid_infix.carbon:[[@LINE+7]]:14: error(ExpectedExpr): expected expression
// CHECK:STDERR: fail_invalid_infix.carbon:[[@LINE+7]]:14: error: expected expression [ExpectedExpr]
// CHECK:STDERR: var c: i32 = == ;
// CHECK:STDERR: ^~
// CHECK:STDERR:
// CHECK:STDERR: fail_invalid_infix.carbon:[[@LINE+3]]:17: error(ExpectedExpr): expected expression
// CHECK:STDERR: fail_invalid_infix.carbon:[[@LINE+3]]:17: error: expected expression [ExpectedExpr]
// CHECK:STDERR: var c: i32 = == ;
// CHECK:STDERR: ^
var c: i32 = == ;
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/operators/fail_postfix_space.carbon
// CHECK:STDERR: fail_postfix_space.carbon:[[@LINE+3]]:18: error(UnaryOperatorHasWhitespace): whitespace is not allowed before this unary operator
// CHECK:STDERR: fail_postfix_space.carbon:[[@LINE+3]]:18: error: whitespace is not allowed before this unary operator [UnaryOperatorHasWhitespace]
// CHECK:STDERR: var v: type = i8 *;
// CHECK:STDERR: ^
var v: type = i8 *;
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/operators/fail_postfix_space_before_comma.carbon
// CHECK:STDERR: fail_postfix_space_before_comma.carbon:[[@LINE+3]]:18: error(UnaryOperatorHasWhitespace): whitespace is not allowed before this unary operator
// CHECK:STDERR: fail_postfix_space_before_comma.carbon:[[@LINE+3]]:18: error: whitespace is not allowed before this unary operator [UnaryOperatorHasWhitespace]
// CHECK:STDERR: var n: i8 = F(i8 *, 0);
// CHECK:STDERR: ^
var n: i8 = F(i8 *, 0);
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/operators/fail_postfix_space_in_call.carbon
// CHECK:STDERR: fail_postfix_space_in_call.carbon:[[@LINE+3]]:18: error(UnaryOperatorHasWhitespace): whitespace is not allowed before this unary operator
// CHECK:STDERR: fail_postfix_space_in_call.carbon:[[@LINE+3]]:18: error: whitespace is not allowed before this unary operator [UnaryOperatorHasWhitespace]
// CHECK:STDERR: var n: i8 = F(i8 *);
// CHECK:STDERR: ^
var n: i8 = F(i8 *);
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/operators/fail_postfix_space_surrounding.carbon
// CHECK:STDERR: fail_postfix_space_surrounding.carbon:[[@LINE+3]]:18: error(UnaryOperatorHasWhitespace): whitespace is not allowed before this unary operator
// CHECK:STDERR: fail_postfix_space_surrounding.carbon:[[@LINE+3]]:18: error: whitespace is not allowed before this unary operator [UnaryOperatorHasWhitespace]
// CHECK:STDERR: var v: type = i8 * ;
// CHECK:STDERR: ^
var v: type = i8 * ;
@@ -11,12 +11,12 @@
fn F() {
var n: i32 = 0;
// TODO: It'd be nice to produce a custom diagnostic here.
// CHECK:STDERR: fail_postincrement.carbon:[[@LINE+4]]:4: error(ExpectedExprSemi): expected `;` after expression statement
// CHECK:STDERR: fail_postincrement.carbon:[[@LINE+4]]:4: error: expected `;` after expression statement [ExpectedExprSemi]
// CHECK:STDERR: n++;
// CHECK:STDERR: ^~
// CHECK:STDERR:
n++;
// CHECK:STDERR: fail_postincrement.carbon:[[@LINE+3]]:4: error(ExpectedExprSemi): expected `;` after expression statement
// CHECK:STDERR: fail_postincrement.carbon:[[@LINE+3]]:4: error: expected `;` after expression statement [ExpectedExprSemi]
// CHECK:STDERR: n--;
// CHECK:STDERR: ^~
n--;
@@ -9,7 +9,7 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/operators/fail_precedence_and_or.carbon
fn F() {
// CHECK:STDERR: fail_precedence_and_or.carbon:[[@LINE+3]]:11: error(OperatorRequiresParentheses): parentheses are required to disambiguate operator precedence
// CHECK:STDERR: fail_precedence_and_or.carbon:[[@LINE+3]]:11: error: parentheses are required to disambiguate operator precedence [OperatorRequiresParentheses]
// CHECK:STDERR: a and b or c;
// CHECK:STDERR: ^~
a and b or c;
@@ -10,43 +10,43 @@
fn F(n: i32) {
// No ordering between `not` and `as`.
// CHECK:STDERR: fail_precedence_as.carbon:[[@LINE+4]]:12: error(OperatorRequiresParentheses): parentheses are required to disambiguate operator precedence
// CHECK:STDERR: fail_precedence_as.carbon:[[@LINE+4]]:12: error: parentheses are required to disambiguate operator precedence [OperatorRequiresParentheses]
// CHECK:STDERR: not true as bool;
// CHECK:STDERR: ^~
// CHECK:STDERR:
not true as bool;
// No ordering between mathematical binary operators and `as`.
// CHECK:STDERR: fail_precedence_as.carbon:[[@LINE+4]]:9: error(OperatorRequiresParentheses): parentheses are required to disambiguate operator precedence
// CHECK:STDERR: fail_precedence_as.carbon:[[@LINE+4]]:9: error: parentheses are required to disambiguate operator precedence [OperatorRequiresParentheses]
// CHECK:STDERR: 1 + 1 as i32;
// CHECK:STDERR: ^~
// CHECK:STDERR:
1 + 1 as i32;
// CHECK:STDERR: fail_precedence_as.carbon:[[@LINE+4]]:9: error(OperatorRequiresParentheses): parentheses are required to disambiguate operator precedence
// CHECK:STDERR: fail_precedence_as.carbon:[[@LINE+4]]:9: error: parentheses are required to disambiguate operator precedence [OperatorRequiresParentheses]
// CHECK:STDERR: 5 % 2 as i32;
// CHECK:STDERR: ^~
// CHECK:STDERR:
5 % 2 as i32;
// No ordering between logical binary operators and `as`.
// CHECK:STDERR: fail_precedence_as.carbon:[[@LINE+4]]:12: error(OperatorRequiresParentheses): parentheses are required to disambiguate operator precedence
// CHECK:STDERR: fail_precedence_as.carbon:[[@LINE+4]]:12: error: parentheses are required to disambiguate operator precedence [OperatorRequiresParentheses]
// CHECK:STDERR: 3 as i32 and true;
// CHECK:STDERR: ^~~
// CHECK:STDERR:
3 as i32 and true;
// CHECK:STDERR: fail_precedence_as.carbon:[[@LINE+4]]:14: error(OperatorRequiresParentheses): parentheses are required to disambiguate operator precedence
// CHECK:STDERR: fail_precedence_as.carbon:[[@LINE+4]]:14: error: parentheses are required to disambiguate operator precedence [OperatorRequiresParentheses]
// CHECK:STDERR: false or 4 as i32;
// CHECK:STDERR: ^~
// CHECK:STDERR:
false or 4 as i32;
// No ordering between relational binary operators and `as`.
// CHECK:STDERR: fail_precedence_as.carbon:[[@LINE+4]]:12: error(OperatorRequiresParentheses): parentheses are required to disambiguate operator precedence
// CHECK:STDERR: fail_precedence_as.carbon:[[@LINE+4]]:12: error: parentheses are required to disambiguate operator precedence [OperatorRequiresParentheses]
// CHECK:STDERR: 6 as i32 == 7;
// CHECK:STDERR: ^~
// CHECK:STDERR:
6 as i32 == 7;
// CHECK:STDERR: fail_precedence_as.carbon:[[@LINE+3]]:10: error(OperatorRequiresParentheses): parentheses are required to disambiguate operator precedence
// CHECK:STDERR: fail_precedence_as.carbon:[[@LINE+3]]:10: error: parentheses are required to disambiguate operator precedence [OperatorRequiresParentheses]
// CHECK:STDERR: 8 <= 9 as i32;
// CHECK:STDERR: ^~
8 <= 9 as i32;
@@ -12,26 +12,26 @@ fn F() {
var a: i32;
// Assignment can only appear as an expression statement, not as a subexpression.
// TODO: Produce the "can only be used as a complete statement" diagnostic in each of these cases.
// CHECK:STDERR: fail_precedence_assign.carbon:[[@LINE+4]]:10: error(UnexpectedTokenAfterListElement): expected `,` or `)`
// CHECK:STDERR: fail_precedence_assign.carbon:[[@LINE+4]]:10: error: expected `,` or `)` [UnexpectedTokenAfterListElement]
// CHECK:STDERR: 1 + (a = 1);
// CHECK:STDERR: ^
// CHECK:STDERR:
1 + (a = 1);
// CHECK:STDERR: fail_precedence_assign.carbon:[[@LINE+8]]:19: error(ExpectedElseAfterIf): expected `else` after `if ... then ...`
// CHECK:STDERR: fail_precedence_assign.carbon:[[@LINE+8]]:19: error: expected `else` after `if ... then ...` [ExpectedElseAfterIf]
// CHECK:STDERR: (if true then a += 1 else a /= 2);
// CHECK:STDERR: ^~
// CHECK:STDERR:
// CHECK:STDERR: fail_precedence_assign.carbon:[[@LINE+4]]:19: error(UnexpectedTokenAfterListElement): expected `,` or `)`
// CHECK:STDERR: fail_precedence_assign.carbon:[[@LINE+4]]:19: error: expected `,` or `)` [UnexpectedTokenAfterListElement]
// CHECK:STDERR: (if true then a += 1 else a /= 2);
// CHECK:STDERR: ^~
// CHECK:STDERR:
(if true then a += 1 else a /= 2);
// CHECK:STDERR: fail_precedence_assign.carbon:[[@LINE+4]]:7: error(StatementOperatorAsSubExpr): operator `++` can only be used as a complete statement
// CHECK:STDERR: fail_precedence_assign.carbon:[[@LINE+4]]:7: error: operator `++` can only be used as a complete statement [StatementOperatorAsSubExpr]
// CHECK:STDERR: a + ++a;
// CHECK:STDERR: ^~
// CHECK:STDERR:
a + ++a;
// CHECK:STDERR: fail_precedence_assign.carbon:[[@LINE+3]]:5: error(UnaryOperatorRequiresParentheses): parentheses are required around this unary `if` operator
// CHECK:STDERR: fail_precedence_assign.carbon:[[@LINE+3]]:5: error: parentheses are required around this unary `if` operator [UnaryOperatorRequiresParentheses]
// CHECK:STDERR: ++if c then a else b;
// CHECK:STDERR: ^~
++if c then a else b;
@@ -9,7 +9,7 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/operators/fail_precedence_or_and.carbon
fn F() {
// CHECK:STDERR: fail_precedence_or_and.carbon:[[@LINE+3]]:10: error(OperatorRequiresParentheses): parentheses are required to disambiguate operator precedence
// CHECK:STDERR: fail_precedence_or_and.carbon:[[@LINE+3]]:10: error: parentheses are required to disambiguate operator precedence [OperatorRequiresParentheses]
// CHECK:STDERR: a or b and c;
// CHECK:STDERR: ^~~
a or b and c;
@@ -11,7 +11,7 @@
// --- fail_and_where.carbon
fn AndWhere() {
// CHECK:STDERR: fail_and_where.carbon:[[@LINE+4]]:14: error(OperatorRequiresParentheses): parentheses are required to disambiguate operator precedence
// CHECK:STDERR: fail_and_where.carbon:[[@LINE+4]]:14: error: parentheses are required to disambiguate operator precedence [OperatorRequiresParentheses]
// CHECK:STDERR: true and T where .A = B;
// CHECK:STDERR: ^~~~~
// CHECK:STDERR:
@@ -21,7 +21,7 @@ fn AndWhere() {
// --- fail_where_or.carbon
fn WhereOr() {
// CHECK:STDERR: fail_where_or.carbon:[[@LINE+4]]:22: error(ExpectedExprSemi): expected `;` after expression statement
// CHECK:STDERR: fail_where_or.carbon:[[@LINE+4]]:22: error: expected `;` after expression statement [ExpectedExprSemi]
// CHECK:STDERR: U where .C impls D or false;
// CHECK:STDERR: ^~
// CHECK:STDERR:
@@ -31,7 +31,7 @@ fn WhereOr() {
// --- fail_equals_where.carbon
fn EqualsWhere() {
// CHECK:STDERR: fail_equals_where.carbon:[[@LINE+4]]:10: error(OperatorRequiresParentheses): parentheses are required to disambiguate operator precedence
// CHECK:STDERR: fail_equals_where.carbon:[[@LINE+4]]:10: error: parentheses are required to disambiguate operator precedence [OperatorRequiresParentheses]
// CHECK:STDERR: e == V where .G == f32;
// CHECK:STDERR: ^~~~~
// CHECK:STDERR:
@@ -41,7 +41,7 @@ fn EqualsWhere() {
// --- fail_where_neq.carbon
fn WhereNEq() {
// CHECK:STDERR: fail_where_neq.carbon:[[@LINE+4]]:21: error(ExpectedExprSemi): expected `;` after expression statement
// CHECK:STDERR: fail_where_neq.carbon:[[@LINE+4]]:21: error: expected `;` after expression statement [ExpectedExprSemi]
// CHECK:STDERR: W where .H = bool != i;
// CHECK:STDERR: ^~
// CHECK:STDERR:
@@ -51,7 +51,7 @@ fn WhereNEq() {
// --- fail_less_requirement.carbon
fn LessRequirement() {
// CHECK:STDERR: fail_less_requirement.carbon:[[@LINE+4]]:14: error(ExpectedRequirementOperator): requirement should use `impls`, `=`, or `==` operator
// CHECK:STDERR: fail_less_requirement.carbon:[[@LINE+4]]:14: error: requirement should use `impls`, `=`, or `==` operator [ExpectedRequirementOperator]
// CHECK:STDERR: X where .J < .K;
// CHECK:STDERR: ^
// CHECK:STDERR:
@@ -61,7 +61,7 @@ fn LessRequirement() {
// --- fail_as_where.carbon
fn AsWhere() {
// CHECK:STDERR: fail_as_where.carbon:[[@LINE+4]]:10: error(OperatorRequiresParentheses): parentheses are required to disambiguate operator precedence
// CHECK:STDERR: fail_as_where.carbon:[[@LINE+4]]:10: error: parentheses are required to disambiguate operator precedence [OperatorRequiresParentheses]
// CHECK:STDERR: Y as Z where .L impls M;
// CHECK:STDERR: ^~~~~
// CHECK:STDERR:
@@ -71,7 +71,7 @@ fn AsWhere() {
// --- fail_where_as.carbon
fn WhereAs() {
// CHECK:STDERR: fail_where_as.carbon:[[@LINE+4]]:21: error(ExpectedExprSemi): expected `;` after expression statement
// CHECK:STDERR: fail_where_as.carbon:[[@LINE+4]]:21: error: expected `;` after expression statement [ExpectedExprSemi]
// CHECK:STDERR: S where .N == i32 as type;
// CHECK:STDERR: ^~
// CHECK:STDERR:
@@ -81,7 +81,7 @@ fn WhereAs() {
// --- fail_as_in_argument.carbon
fn AsInArgument() {
// CHECK:STDERR: fail_as_in_argument.carbon:[[@LINE+4]]:14: error(ExpectedRequirementOperator): requirement should use `impls`, `=`, or `==` operator
// CHECK:STDERR: fail_as_in_argument.carbon:[[@LINE+4]]:14: error: requirement should use `impls`, `=`, or `==` operator [ExpectedRequirementOperator]
// CHECK:STDERR: R where .O as type impls P;
// CHECK:STDERR: ^~
// CHECK:STDERR:
@@ -91,7 +91,7 @@ fn AsInArgument() {
// --- fail_greater_in_argument.carbon
fn GreaterInArgument() {
// CHECK:STDERR: fail_greater_in_argument.carbon:[[@LINE+3]]:15: error(ExpectedRequirementOperator): requirement should use `impls`, `=`, or `==` operator
// CHECK:STDERR: fail_greater_in_argument.carbon:[[@LINE+3]]:15: error: requirement should use `impls`, `=`, or `==` operator [ExpectedRequirementOperator]
// CHECK:STDERR: Q where .AA > .BB impls CC;
// CHECK:STDERR: ^
Q where .AA > .BB impls CC;
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/operators/fail_prefix_repeat.carbon
// CHECK:STDERR: fail_prefix_repeat.carbon:[[@LINE+3]]:17: error(UnaryOperatorRequiresParentheses): parentheses are required around this unary `const` operator
// CHECK:STDERR: fail_prefix_repeat.carbon:[[@LINE+3]]:17: error: parentheses are required around this unary `const` operator [UnaryOperatorRequiresParentheses]
// CHECK:STDERR: fn F() -> const const i32* {
// CHECK:STDERR: ^~~~~
fn F() -> const const i32* {
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/operators/fail_prefix_space.carbon
// CHECK:STDERR: fail_prefix_space.carbon:[[@LINE+3]]:13: error(UnaryOperatorHasWhitespace): whitespace is not allowed after this unary operator
// CHECK:STDERR: fail_prefix_space.carbon:[[@LINE+3]]:13: error: whitespace is not allowed after this unary operator [UnaryOperatorHasWhitespace]
// CHECK:STDERR: var n: i8 = - n;
// CHECK:STDERR: ^
var n: i8 = - n;
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/operators/fail_prefix_uneven_space_with_assign.carbon
// CHECK:STDERR: fail_prefix_uneven_space_with_assign.carbon:[[@LINE+3]]:12: error(UnaryOperatorHasWhitespace): whitespace is not allowed after this unary operator
// CHECK:STDERR: fail_prefix_uneven_space_with_assign.carbon:[[@LINE+3]]:12: error: whitespace is not allowed after this unary operator [UnaryOperatorHasWhitespace]
// CHECK:STDERR: var n: i8 =- n;
// CHECK:STDERR: ^
var n: i8 =- n;
+1 -1
View File
@@ -13,7 +13,7 @@
// available because it has already accepted that first part of the expression,
// so it is recovering by using the second option, but the diagnostic should
// ideally offer (or consider) both fixes as alternatives.
// CHECK:STDERR: fail_star_minus.carbon:[[@LINE+3]]:16: error(BinaryOperatorRequiresWhitespace): whitespace missing after binary operator
// CHECK:STDERR: fail_star_minus.carbon:[[@LINE+3]]:16: error: whitespace missing after binary operator [BinaryOperatorRequiresWhitespace]
// CHECK:STDERR: var n: i8 = n* -n;
// CHECK:STDERR: ^
var n: i8 = n* -n;
+1 -1
View File
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/operators/fail_star_star.carbon
// CHECK:STDERR: fail_star_star.carbon:[[@LINE+3]]:16: error(BinaryOperatorRequiresWhitespace): whitespace missing after binary operator
// CHECK:STDERR: fail_star_star.carbon:[[@LINE+3]]:16: error: whitespace missing after binary operator [BinaryOperatorRequiresWhitespace]
// CHECK:STDERR: var n: i8 = n* *p;
// CHECK:STDERR: ^
var n: i8 = n* *p;
@@ -12,7 +12,7 @@
// before we notice the missing whitespace around the second `*`.
// It'd be better to (somehow) form n*(*p) and reject due to the missing
// whitespace around the first `*`.
// CHECK:STDERR: fail_star_star_no_space.carbon:[[@LINE+3]]:16: error(ExpectedDeclSemi): `var` declarations must end with a `;`
// CHECK:STDERR: fail_star_star_no_space.carbon:[[@LINE+3]]:16: error: `var` declarations must end with a `;` [ExpectedDeclSemi]
// CHECK:STDERR: var n: i8 = n**p;
// CHECK:STDERR: ^
var n: i8 = n**p;
+5 -5
View File
@@ -9,23 +9,23 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/operators/fail_variety.carbon
fn F() {
// CHECK:STDERR: fail_variety.carbon:[[@LINE+19]]:21: error(StatementOperatorAsSubExpr): operator `=` can only be used as a complete statement
// CHECK:STDERR: fail_variety.carbon:[[@LINE+19]]:21: error: operator `=` can only be used as a complete statement [StatementOperatorAsSubExpr]
// CHECK:STDERR: n = a * b + c * d = d * d << e & f - not g;
// CHECK:STDERR: ^
// CHECK:STDERR:
// CHECK:STDERR: fail_variety.carbon:[[@LINE+15]]:29: error(OperatorRequiresParentheses): parentheses are required to disambiguate operator precedence
// CHECK:STDERR: fail_variety.carbon:[[@LINE+15]]:29: error: parentheses are required to disambiguate operator precedence [OperatorRequiresParentheses]
// CHECK:STDERR: n = a * b + c * d = d * d << e & f - not g;
// CHECK:STDERR: ^~
// CHECK:STDERR:
// CHECK:STDERR: fail_variety.carbon:[[@LINE+11]]:34: error(OperatorRequiresParentheses): parentheses are required to disambiguate operator precedence
// CHECK:STDERR: fail_variety.carbon:[[@LINE+11]]:34: error: parentheses are required to disambiguate operator precedence [OperatorRequiresParentheses]
// CHECK:STDERR: n = a * b + c * d = d * d << e & f - not g;
// CHECK:STDERR: ^
// CHECK:STDERR:
// CHECK:STDERR: fail_variety.carbon:[[@LINE+7]]:38: error(OperatorRequiresParentheses): parentheses are required to disambiguate operator precedence
// CHECK:STDERR: fail_variety.carbon:[[@LINE+7]]:38: error: parentheses are required to disambiguate operator precedence [OperatorRequiresParentheses]
// CHECK:STDERR: n = a * b + c * d = d * d << e & f - not g;
// CHECK:STDERR: ^
// CHECK:STDERR:
// CHECK:STDERR: fail_variety.carbon:[[@LINE+3]]:40: error(UnaryOperatorRequiresParentheses): parentheses are required around this unary `not` operator
// CHECK:STDERR: fail_variety.carbon:[[@LINE+3]]:40: error: parentheses are required around this unary `not` operator [UnaryOperatorRequiresParentheses]
// CHECK:STDERR: n = a * b + c * d = d * d << e & f - not g;
// CHECK:STDERR: ^~~
n = a * b + c * d = d * d << e & f - not g;