diff --git a/toolchain/diagnostics/diagnostic_kind.def b/toolchain/diagnostics/diagnostic_kind.def index 8a6f33a69eef..4eaefcb8eb37 100644 --- a/toolchain/diagnostics/diagnostic_kind.def +++ b/toolchain/diagnostics/diagnostic_kind.def @@ -64,7 +64,7 @@ CARBON_DIAGNOSTIC_KIND(ExpectedArraySemi) CARBON_DIAGNOSTIC_KIND(ExpectedCloseSymbol) CARBON_DIAGNOSTIC_KIND(ExpectedCodeBlock) CARBON_DIAGNOSTIC_KIND(ExpectedExpr) -CARBON_DIAGNOSTIC_KIND(ExpectedIdentifierAfterDotOrArrow) +CARBON_DIAGNOSTIC_KIND(ExpectedIdentifierAfterPeriodOrArrow) CARBON_DIAGNOSTIC_KIND(ExpectedBindingPattern) CARBON_DIAGNOSTIC_KIND(ExpectedParenAfter) CARBON_DIAGNOSTIC_KIND(ExpectedExprSemi) diff --git a/toolchain/parse/handle_period.cpp b/toolchain/parse/handle_period.cpp index 7675a8b0e720..d620c9437a08 100644 --- a/toolchain/parse/handle_period.cpp +++ b/toolchain/parse/handle_period.cpp @@ -35,10 +35,10 @@ static auto HandlePeriodOrArrow(Context& context, NodeKind node_kind, context.PushState(State::OnlyParenExpr); return; } else { - CARBON_DIAGNOSTIC(ExpectedIdentifierAfterDotOrArrow, Error, + CARBON_DIAGNOSTIC(ExpectedIdentifierAfterPeriodOrArrow, Error, "Expected identifier after `{0}`.", llvm::StringLiteral); context.emitter().Emit( - *context.position(), ExpectedIdentifierAfterDotOrArrow, + *context.position(), ExpectedIdentifierAfterPeriodOrArrow, is_arrow ? llvm::StringLiteral("->") : llvm::StringLiteral(".")); // If we see a keyword, assume it was intended to be a name. // TODO: Should keywords be valid here? diff --git a/toolchain/parse/testdata/struct/fail_dot_only.carbon b/toolchain/parse/testdata/struct/fail_period_only.carbon similarity index 84% rename from toolchain/parse/testdata/struct/fail_dot_only.carbon rename to toolchain/parse/testdata/struct/fail_period_only.carbon index 2876ae99cd15..7b491126689e 100644 --- a/toolchain/parse/testdata/struct/fail_dot_only.carbon +++ b/toolchain/parse/testdata/struct/fail_period_only.carbon @@ -4,16 +4,16 @@ // // AUTOUPDATE // TIP: To test this file alone, run: -// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/parse/testdata/struct/fail_dot_only.carbon +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/parse/testdata/struct/fail_period_only.carbon // TIP: To dump output, run: -// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_dot_only.carbon +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_period_only.carbon -// CHECK:STDERR: fail_dot_only.carbon:[[@LINE+3]]:10: ERROR: Expected identifier after `.`. +// CHECK:STDERR: fail_period_only.carbon:[[@LINE+3]]:10: ERROR: Expected identifier after `.`. // CHECK:STDERR: var x: {.} = {}; // CHECK:STDERR: ^ var x: {.} = {}; -// CHECK:STDOUT: - filename: fail_dot_only.carbon +// CHECK:STDOUT: - filename: fail_period_only.carbon // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, diff --git a/toolchain/parse/testdata/struct/fail_dot_paren.carbon b/toolchain/parse/testdata/struct/fail_period_paren.carbon similarity index 82% rename from toolchain/parse/testdata/struct/fail_dot_paren.carbon rename to toolchain/parse/testdata/struct/fail_period_paren.carbon index 22b6c4ef9d50..0d2d121cc9f1 100644 --- a/toolchain/parse/testdata/struct/fail_dot_paren.carbon +++ b/toolchain/parse/testdata/struct/fail_period_paren.carbon @@ -4,16 +4,16 @@ // // AUTOUPDATE // TIP: To test this file alone, run: -// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/parse/testdata/struct/fail_dot_paren.carbon +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/parse/testdata/struct/fail_period_paren.carbon // TIP: To dump output, run: -// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_dot_paren.carbon +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_period_paren.carbon -// CHECK:STDERR: fail_dot_paren.carbon:[[@LINE+3]]:10: ERROR: Expected identifier after `.`. +// CHECK:STDERR: fail_period_paren.carbon:[[@LINE+3]]:10: ERROR: Expected identifier after `.`. // CHECK:STDERR: var x: {.(a) = 1}; // CHECK:STDERR: ^ var x: {.(a) = 1}; -// CHECK:STDOUT: - filename: fail_dot_paren.carbon +// CHECK:STDOUT: - filename: fail_period_paren.carbon // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, diff --git a/toolchain/parse/testdata/struct/fail_dot_string_colon.carbon b/toolchain/parse/testdata/struct/fail_period_string_colon.carbon similarity index 86% rename from toolchain/parse/testdata/struct/fail_dot_string_colon.carbon rename to toolchain/parse/testdata/struct/fail_period_string_colon.carbon index ffcaa1e2f2ba..b0be9b6a1887 100644 --- a/toolchain/parse/testdata/struct/fail_dot_string_colon.carbon +++ b/toolchain/parse/testdata/struct/fail_period_string_colon.carbon @@ -4,16 +4,16 @@ // // AUTOUPDATE // TIP: To test this file alone, run: -// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/parse/testdata/struct/fail_dot_string_colon.carbon +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/parse/testdata/struct/fail_period_string_colon.carbon // TIP: To dump output, run: -// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_dot_string_colon.carbon +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_period_string_colon.carbon -// CHECK:STDERR: fail_dot_string_colon.carbon:[[@LINE+3]]:10: ERROR: Expected identifier after `.`. +// CHECK:STDERR: fail_period_string_colon.carbon:[[@LINE+3]]:10: ERROR: Expected identifier after `.`. // CHECK:STDERR: var x: {."hello": i32, .y: i32} = {}; // CHECK:STDERR: ^~~~~~~ var x: {."hello": i32, .y: i32} = {}; -// CHECK:STDOUT: - filename: fail_dot_string_colon.carbon +// CHECK:STDOUT: - filename: fail_period_string_colon.carbon // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, diff --git a/toolchain/parse/testdata/struct/fail_dot_string_equals.carbon b/toolchain/parse/testdata/struct/fail_period_string_equals.carbon similarity index 86% rename from toolchain/parse/testdata/struct/fail_dot_string_equals.carbon rename to toolchain/parse/testdata/struct/fail_period_string_equals.carbon index beb677cfceaf..41484b8c8dcd 100644 --- a/toolchain/parse/testdata/struct/fail_dot_string_equals.carbon +++ b/toolchain/parse/testdata/struct/fail_period_string_equals.carbon @@ -4,16 +4,16 @@ // // AUTOUPDATE // TIP: To test this file alone, run: -// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/parse/testdata/struct/fail_dot_string_equals.carbon +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/parse/testdata/struct/fail_period_string_equals.carbon // TIP: To dump output, run: -// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_dot_string_equals.carbon +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_period_string_equals.carbon -// CHECK:STDERR: fail_dot_string_equals.carbon:[[@LINE+3]]:10: ERROR: Expected identifier after `.`. +// CHECK:STDERR: fail_period_string_equals.carbon:[[@LINE+3]]:10: ERROR: Expected identifier after `.`. // CHECK:STDERR: var x: {."hello" = 0, .y = 4} = {}; // CHECK:STDERR: ^~~~~~~ var x: {."hello" = 0, .y = 4} = {}; -// CHECK:STDOUT: - filename: fail_dot_string_equals.carbon +// CHECK:STDOUT: - filename: fail_period_string_equals.carbon // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},