From 65a4e006a2c79b8c8ed623a43123518ccfafceac Mon Sep 17 00:00:00 2001 From: Jon Ross-Perkins Date: Fri, 21 Jul 2023 16:53:36 -0700 Subject: [PATCH] Add line output to diagnostics to help identify error locations. (#3010) This also makes the filename a reference to the buffer since the line seems better to have as a reference (versus copying a string per error). Most tests now have different line deltas due to the extra output, but the actual errors should overall stay the same. Some of the error locations look like they could be improved, but this change is only making it clear where they were before. --- toolchain/diagnostics/diagnostic_emitter.h | 15 ++++-- .../sorting_diagnostic_consumer_test.cpp | 12 ++--- toolchain/driver/driver.cpp | 9 ++-- .../driver/testdata/errors_sorted_test.carbon | 8 +++- .../testdata/errors_streamed_test.carbon | 8 +++- toolchain/lexer/tokenized_buffer.cpp | 20 ++++++-- toolchain/lexer/tokenized_buffer.h | 4 ++ .../basics/fail_before_lowering.carbon | 4 +- .../basics/fail_invalid_designators.carbon | 12 +++-- .../basics/fail_no_intro_with_semi.carbon | 4 +- .../basics/fail_no_intro_without_semi.carbon | 4 +- .../basics/fail_paren_match_regression.carbon | 12 +++-- .../for/fail_colon_instead_of_in.carbon | 4 +- .../testdata/for/fail_missing_in.carbon | 4 +- .../testdata/for/fail_missing_var.carbon | 4 +- .../fail_identifier_instead_of_sig.carbon | 4 +- .../fail_missing_deduced_close.carbon | 12 +++-- .../declaration/fail_missing_name.carbon | 4 +- .../declaration/fail_no_sig_or_semi.carbon | 4 +- .../declaration/fail_only_fn_and_semi.carbon | 4 +- .../fail_repeated_fn_and_semi.carbon | 4 +- ...skip_indented_newline_until_outdent.carbon | 4 +- ...ail_skip_indented_newline_with_semi.carbon | 4 +- ..._skip_indented_newline_without_semi.carbon | 4 +- .../fail_skip_to_newline_without_semi.carbon | 4 +- .../fail_skip_without_semi_to_curly.carbon | 4 +- .../fail_with_identifier_as_param.carbon | 4 +- ...hout_name_and_many_tokens_in_params.carbon | 4 +- .../fail_identifier_in_statements.carbon | 4 +- .../deduced_params/fail_no_parens.carbon | 16 +++++-- .../interface/fail_missing_name.carbon | 4 +- .../interface/fail_missing_open_curly.carbon | 8 +++- .../interface/fail_no_impl_allowed.carbon | 4 +- .../interface/fail_self_param_syntax.carbon | 8 +++- .../fail_no_impl_allowed.carbon | 4 +- .../testdata/if/fail_else_unbraced.carbon | 16 +++++-- .../parser/testdata/if/fail_errors.carbon | 20 ++++++-- .../parser/testdata/if/fail_unbraced.carbon | 12 +++-- .../fail_condition_missing.carbon | 4 +- .../fail_else_expr_missing.carbon | 4 +- .../if_expression/fail_else_missing.carbon | 4 +- .../fail_then_expr_missing.carbon | 4 +- .../if_expression/fail_then_missing.carbon | 4 +- .../if_expression/fail_top_level_if.carbon | 12 +++-- .../testdata/namespace/fail_args.carbon | 4 +- .../namespace/fail_incomplete_name.carbon | 4 +- .../testdata/namespace/fail_no_name.carbon | 4 +- .../fail_infix_uneven_space_after.carbon | 4 +- .../operators/fail_invalid_infix.carbon | 16 +++++-- .../operators/fail_precedence_and_or.carbon | 4 +- .../operators/fail_precedence_or_and.carbon | 4 +- .../fail_precedence_star_minus.carbon | 4 +- .../fail_precedence_star_star.carbon | 4 +- .../operators/fail_star_star_no_space.carbon | 4 +- .../testdata/operators/fail_variety.carbon | 16 +++++-- .../recover_infix_uneven_space_before.carbon | 4 +- .../operators/recover_postfix_space.carbon | 4 +- .../recover_postfix_space_before_comma.carbon | 4 +- .../recover_postfix_space_in_call.carbon | 4 +- .../recover_postfix_space_surrounding.carbon | 4 +- .../operators/recover_prefix_space.carbon | 4 +- ...ver_prefix_uneven_space_with_assign.carbon | 4 +- .../testdata/package/fail_extra_string.carbon | 4 +- .../package/fail_library_is_identifier.carbon | 4 +- .../package/fail_library_skips_name.carbon | 4 +- .../package/fail_name_is_keyword.carbon | 4 +- .../testdata/package/fail_no_name.carbon | 4 +- .../testdata/package/fail_no_semi.carbon | 4 +- .../testdata/package/fail_no_type.carbon | 4 +- .../package/fail_omit_library_keyword.carbon | 4 +- .../testdata/return/fail_expr_no_semi.carbon | 4 +- .../testdata/return/fail_no_semi.carbon | 8 +++- .../testdata/struct/fail_comma_only.carbon | 4 +- .../struct/fail_comma_repeat_in_type.carbon | 4 +- .../struct/fail_comma_repeat_in_value.carbon | 4 +- .../testdata/struct/fail_dot_only.carbon | 4 +- .../struct/fail_dot_string_colon.carbon | 4 +- .../struct/fail_dot_string_equals.carbon | 4 +- .../struct/fail_extra_token_in_type.carbon | 4 +- .../struct/fail_extra_token_in_value.carbon | 4 +- .../struct/fail_identifier_colon.carbon | 4 +- .../struct/fail_identifier_equals.carbon | 4 +- .../struct/fail_identifier_only.carbon | 4 +- .../testdata/struct/fail_missing_type.carbon | 4 +- .../testdata/struct/fail_missing_value.carbon | 4 +- .../struct/fail_mix_type_and_value.carbon | 4 +- .../struct/fail_mix_value_and_type.carbon | 4 +- .../struct/fail_mix_with_unknown.carbon | 16 +++++-- .../struct/fail_no_colon_or_equals.carbon | 4 +- .../struct/fail_type_no_designator.carbon | 4 +- .../parser/testdata/var/fail_bad_name.carbon | 4 +- .../parser/testdata/var/fail_empty.carbon | 4 +- .../parser/testdata/while/fail_no_semi.carbon | 8 +++- .../testdata/while/fail_unbraced.carbon | 4 +- .../testdata/basics/fail_name_lookup.carbon | 4 +- .../basics/fail_qualifier_unsupported.carbon | 4 +- .../function/call/fail_param_count.carbon | 48 ++++++++++++++----- .../function/call/fail_param_type.carbon | 8 +++- .../call/fail_return_type_mismatch.carbon | 4 +- .../fail_param_name_conflict.carbon | 8 +++- .../if/fail_reachable_fallthrough.carbon | 12 +++-- .../semantics/testdata/if/fail_scope.carbon | 4 +- .../testdata/namespace/fail_duplicate.carbon | 8 +++- .../namespace/fail_unresolved_scope.carbon | 4 +- .../operators/fail_type_mismatch.carbon | 4 +- .../operators/fail_type_mismatch_once.carbon | 4 +- .../return/fail_missing_return.carbon | 4 +- .../fail_missing_return_empty_tuple.carbon | 4 +- .../testdata/return/fail_type_mismatch.carbon | 4 +- .../return/fail_value_disallowed.carbon | 8 +++- .../testdata/return/fail_value_missing.carbon | 4 +- .../testdata/struct/fail_assign_empty.carbon | 4 +- .../struct/fail_assign_to_empty.carbon | 4 +- .../struct/fail_field_name_mismatch.carbon | 4 +- .../struct/fail_field_type_mismatch.carbon | 4 +- .../struct/fail_member_access_type.carbon | 4 +- .../struct/fail_non_member_access.carbon | 4 +- .../struct/fail_too_few_values.carbon | 4 +- .../testdata/struct/fail_type_assign.carbon | 4 +- .../testdata/struct/fail_value_as_type.carbon | 4 +- .../testdata/tuples/fail_assign_empty.carbon | 4 +- .../tuples/fail_assign_to_empty.carbon | 4 +- .../tuples/fail_element_type_mismatch.carbon | 4 +- .../tuples/fail_too_few_element.carbon | 4 +- .../testdata/tuples/fail_type_assign.carbon | 4 +- .../testdata/tuples/fail_value_as_type.carbon | 4 +- .../testdata/var/fail_duplicate_decl.carbon | 8 +++- .../var/fail_init_type_mismatch.carbon | 4 +- .../testdata/var/fail_init_with_self.carbon | 4 +- .../var/fail_lookup_outside_scope.carbon | 4 +- .../var/fail_storage_is_literal.carbon | 4 +- 131 files changed, 578 insertions(+), 198 deletions(-) diff --git a/toolchain/diagnostics/diagnostic_emitter.h b/toolchain/diagnostics/diagnostic_emitter.h index 910c997f5052..271599a94003 100644 --- a/toolchain/diagnostics/diagnostic_emitter.h +++ b/toolchain/diagnostics/diagnostic_emitter.h @@ -45,12 +45,14 @@ enum class DiagnosticLevel : int8_t { ::Carbon::DiagnosticKind::DiagnosticName, \ ::Carbon::DiagnosticLevel::Level, Format) +// A location for a diagnostic in a file. The lifetime of a DiagnosticLocation +// is required to be less than SourceBuffer that it refers to due to the +// contained file_name and line references. struct DiagnosticLocation { // Name of the file or buffer that this diagnostic refers to. - // TODO: Move this out of DiagnosticLocation, as part of an expectation that - // files will be compiled separately, so storing the file's path - // per-diagnostic is wasteful. - std::string file_name; + llvm::StringRef file_name; + // A reference to the line of the error. + llvm::StringRef line; // 1-based line number. int32_t line_number; // 1-based column number. @@ -311,7 +313,10 @@ class StreamDiagnosticConsumer : public DiagnosticConsumer { *stream_ << message.location.file_name << ":" << message.location.line_number << ":" << message.location.column_number << ": " - << message.format_fn(message) << "\n"; + << message.format_fn(message) << "\n" + << message.location.line << "\n"; + stream_->indent(message.location.column_number - 1); + *stream_ << "^\n"; } private: diff --git a/toolchain/diagnostics/sorting_diagnostic_consumer_test.cpp b/toolchain/diagnostics/sorting_diagnostic_consumer_test.cpp index 4cbd86d0d3ed..0ae5e2632b1f 100644 --- a/toolchain/diagnostics/sorting_diagnostic_consumer_test.cpp +++ b/toolchain/diagnostics/sorting_diagnostic_consumer_test.cpp @@ -32,12 +32,12 @@ TEST(SortedDiagnosticEmitterTest, SortErrors) { SortingDiagnosticConsumer sorting_consumer(consumer); DiagnosticEmitter emitter(translator, sorting_consumer); - emitter.Emit({"f", 2, 1}, TestDiagnostic, "M1"); - emitter.Emit({"f", 1, 1}, TestDiagnostic, "M2"); - emitter.Emit({"f", 1, 3}, TestDiagnostic, "M3"); - emitter.Emit({"f", 3, 4}, TestDiagnostic, "M4"); - emitter.Emit({"f", 3, 2}, TestDiagnostic, "M5"); - emitter.Emit({"f", 3, 2}, TestDiagnostic, "M6"); + emitter.Emit({"f", "line", 2, 1}, TestDiagnostic, "M1"); + emitter.Emit({"f", "line", 1, 1}, TestDiagnostic, "M2"); + emitter.Emit({"f", "line", 1, 3}, TestDiagnostic, "M3"); + emitter.Emit({"f", "line", 3, 4}, TestDiagnostic, "M4"); + emitter.Emit({"f", "line", 3, 2}, TestDiagnostic, "M5"); + emitter.Emit({"f", "line", 3, 2}, TestDiagnostic, "M6"); InSequence s; EXPECT_CALL(consumer, HandleDiagnostic( diff --git a/toolchain/driver/driver.cpp b/toolchain/driver/driver.cpp index f3840cf251c3..75dfd1566c1c 100644 --- a/toolchain/driver/driver.cpp +++ b/toolchain/driver/driver.cpp @@ -6,6 +6,7 @@ #include "common/vlog.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/ScopeExit.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSwitch.h" @@ -200,6 +201,9 @@ auto Driver::RunDumpSubcommand(DiagnosticConsumer& consumer, CARBON_VLOG() << "*** SourceBuffer::CreateFromFile ***\n"; auto source = SourceBuffer::CreateFromFile(fs_, input_file_name); CARBON_VLOG() << "*** SourceBuffer::CreateFromFile done ***\n"; + // Require flushing the consumer before the source buffer is destroyed, + // because diagnostics may reference the buffer. + auto flush = llvm::make_scope_exit([&]() { consumer.Flush(); }); if (!source.ok()) { error_stream_ << "ERROR: Unable to open input source file: " << source.error(); @@ -214,7 +218,6 @@ auto Driver::RunDumpSubcommand(DiagnosticConsumer& consumer, CARBON_VLOG() << "*** TokenizedBuffer::Lex done ***\n"; if (dump_mode == DumpMode::TokenizedBuffer) { CARBON_VLOG() << "Finishing output."; - consumer.Flush(); output_stream_ << tokenized_source; return !has_errors; } @@ -225,7 +228,6 @@ auto Driver::RunDumpSubcommand(DiagnosticConsumer& consumer, has_errors |= parse_tree.has_errors(); CARBON_VLOG() << "*** ParseTree::Parse done ***\n"; if (dump_mode == DumpMode::ParseTree) { - consumer.Flush(); parse_tree.Print(output_stream_, parse_tree_preorder); return !has_errors; } @@ -238,7 +240,6 @@ auto Driver::RunDumpSubcommand(DiagnosticConsumer& consumer, has_errors |= semantics_ir.has_errors(); CARBON_VLOG() << "*** SemanticsIR::MakeFromParseTree done ***\n"; if (dump_mode == DumpMode::SemanticsIR) { - consumer.Flush(); semantics_ir.Print(output_stream_, semantics_ir_include_builtins); return !has_errors; } @@ -256,7 +257,6 @@ auto Driver::RunDumpSubcommand(DiagnosticConsumer& consumer, LowerToLLVM(llvm_context, input_file_name, semantics_ir, vlog_stream_); CARBON_VLOG() << "*** LowerToLLVM done ***\n"; if (dump_mode == DumpMode::LLVMIR) { - consumer.Flush(); module->print(output_stream_, /*AAW=*/nullptr, /*ShouldPreserveUseListOrder=*/true); return !has_errors; @@ -269,7 +269,6 @@ auto Driver::RunDumpSubcommand(DiagnosticConsumer& consumer, } if (dump_mode == DumpMode::Assembly) { - consumer.Flush(); CodeGen codegen(*module, target_triple, error_stream_, output_stream_); has_errors |= !codegen.PrintAssembly(); return !has_errors; diff --git a/toolchain/driver/testdata/errors_sorted_test.carbon b/toolchain/driver/testdata/errors_sorted_test.carbon index 92e9f7f2d9f4..cea267ec115d 100644 --- a/toolchain/driver/testdata/errors_sorted_test.carbon +++ b/toolchain/driver/testdata/errors_sorted_test.carbon @@ -7,9 +7,13 @@ // CHECK-COUNT-17:STDOUT: {{.*}} // CHECK:STDOUT: ] -// CHECK:STDERR: {{.*}}/errors_sorted_test.carbon:[[@LINE+1]]:24: Closing symbol does not match most recent opening symbol. +// CHECK:STDERR: {{.*}}/errors_sorted_test.carbon:[[@LINE+3]]:24: Closing symbol does not match most recent opening symbol. +// CHECK:STDERR: fn run(String program) { +// CHECK:STDERR: ^ fn run(String program) { return True; -// CHECK:STDERR: {{.*}}/errors_sorted_test.carbon:[[@LINE+1]]:10: Invalid digit 'a' in decimal numeric literal. +// CHECK:STDERR: {{.*}}/errors_sorted_test.carbon:[[@LINE+3]]:10: Invalid digit 'a' in decimal numeric literal. +// CHECK:STDERR: var x = 3a; +// CHECK:STDERR: ^ var x = 3a; diff --git a/toolchain/driver/testdata/errors_streamed_test.carbon b/toolchain/driver/testdata/errors_streamed_test.carbon index 504653be478f..cf26950b99e0 100644 --- a/toolchain/driver/testdata/errors_streamed_test.carbon +++ b/toolchain/driver/testdata/errors_streamed_test.carbon @@ -13,5 +13,9 @@ fn run(String program) { var x = 3a; -// CHECK:STDERR:{{.*}}/errors_streamed_test.carbon:[[@LINE-2]]:10: Invalid digit 'a' in decimal numeric literal. -// CHECK:STDERR:{{.*}}/errors_streamed_test.carbon:[[@LINE-6]]:24: Closing symbol does not match most recent opening symbol. +// CHECK:STDERR: {{.*}}/errors_streamed_test.carbon:[[@LINE-2]]:10: Invalid digit 'a' in decimal numeric literal. +// CHECK:STDERR: var x = 3a; +// CHECK:STDERR: ^ +// CHECK:STDERR: {{.*}}/errors_streamed_test.carbon:[[@LINE-8]]:24: Closing symbol does not match most recent opening symbol. +// CHECK:STDERR: fn run(String program) { +// CHECK:STDERR: ^ diff --git a/toolchain/lexer/tokenized_buffer.cpp b/toolchain/lexer/tokenized_buffer.cpp index b93351997fb5..9bd5fdc18223 100644 --- a/toolchain/lexer/tokenized_buffer.cpp +++ b/toolchain/lexer/tokenized_buffer.cpp @@ -88,7 +88,7 @@ class TokenizedBuffer::Lexer { emitter_(translator_, consumer), token_translator_(&buffer, ¤t_column_), token_emitter_(token_translator_, consumer), - current_line_(buffer.AddLine({0, 0, 0})), + current_line_(buffer.AddLine(LineInfo(0))), current_line_info_(&buffer.GetLineInfo(current_line_)) {} // Perform the necessary bookkeeping to step past a newline at the current @@ -97,7 +97,7 @@ class TokenizedBuffer::Lexer { current_line_info_->length = current_column_; current_line_ = buffer_->AddLine( - {current_line_info_->start + current_column_ + 1, 0, 0}); + LineInfo(current_line_info_->start + current_column_ + 1)); current_line_info_ = &buffer_->GetLineInfo(current_line_); current_column_ = 0; set_indent_ = false; @@ -907,23 +907,37 @@ auto TokenizedBuffer::SourceBufferLocationTranslator::GetLocation( int line_number = line_it - buffer_->line_infos_.begin(); int column_number = offset - line_it->start; + llvm::StringRef line; + // We might still be lexing the last line. If so, check to see if there are // any newline characters between the position we've finished lexing up to // and the given location. if (incomplete_line_info && column_number > *last_line_lexed_to_column_) { column_number = *last_line_lexed_to_column_; + int64_t start = line_it->start; for (int64_t i = line_it->start + *last_line_lexed_to_column_; i != offset; ++i) { if (buffer_->source_->text()[i] == '\n') { + start = i; ++line_number; column_number = 0; } else { ++column_number; } } + line = buffer_->source_->text().substr(start).take_until( + [](char c) { return c == '\n'; }); + } else if (line_it->length < 0) { + line = + buffer_->source_->text().substr(line_it->start).take_until([](char c) { + return c == '\n'; + }); + } else { + line = buffer_->source_->text().substr(line_it->start, line_it->length); } - return {.file_name = buffer_->source_->filename().str(), + return {.file_name = buffer_->source_->filename(), + .line = line, .line_number = line_number + 1, .column_number = column_number + 1}; } diff --git a/toolchain/lexer/tokenized_buffer.h b/toolchain/lexer/tokenized_buffer.h index bdec1b5c743a..3570805ad1f1 100644 --- a/toolchain/lexer/tokenized_buffer.h +++ b/toolchain/lexer/tokenized_buffer.h @@ -358,6 +358,10 @@ class TokenizedBuffer { }; struct LineInfo { + // The length will always be assigned later. Indent may be assigned if + // non-zero. + explicit LineInfo(int64_t start) : start(start), length(-1), indent(0) {} + // Zero-based byte offset of the start of the line within the source buffer // provided. int64_t start; diff --git a/toolchain/lowering/testdata/basics/fail_before_lowering.carbon b/toolchain/lowering/testdata/basics/fail_before_lowering.carbon index 637d4f5c801c..bd544aa8816a 100644 --- a/toolchain/lowering/testdata/basics/fail_before_lowering.carbon +++ b/toolchain/lowering/testdata/basics/fail_before_lowering.carbon @@ -5,5 +5,7 @@ // This validates that earlier errors prevent lowering, without crashing. // AUTOUPDATE -// CHECK:STDERR: fail_before_lowering.carbon:[[@LINE+1]]:1: Unrecognized declaration introducer. +// CHECK:STDERR: fail_before_lowering.carbon:[[@LINE+3]]:1: Unrecognized declaration introducer. +// CHECK:STDERR: a; +// CHECK:STDERR: ^ a; diff --git a/toolchain/parser/testdata/basics/fail_invalid_designators.carbon b/toolchain/parser/testdata/basics/fail_invalid_designators.carbon index c03f2bce7afb..162ae7e5d960 100644 --- a/toolchain/parser/testdata/basics/fail_invalid_designators.carbon +++ b/toolchain/parser/testdata/basics/fail_invalid_designators.carbon @@ -27,10 +27,16 @@ // NOTE: Move to its own directory when more tests are added. fn F() { - // CHECK:STDERR: fail_invalid_designators.carbon:[[@LINE+1]]:5: Expected identifier after `.`. + // CHECK:STDERR: fail_invalid_designators.carbon:[[@LINE+3]]:5: Expected identifier after `.`. + // CHECK:STDERR: a.; + // CHECK:STDERR: ^ a.; - // CHECK:STDERR: fail_invalid_designators.carbon:[[@LINE+1]]:5: Expected identifier after `.`. + // CHECK:STDERR: fail_invalid_designators.carbon:[[@LINE+3]]:5: Expected identifier after `.`. + // CHECK:STDERR: a.fn; + // CHECK:STDERR: ^ a.fn; - // CHECK:STDERR: fail_invalid_designators.carbon:[[@LINE+1]]:5: Expected identifier after `.`. + // CHECK:STDERR: fail_invalid_designators.carbon:[[@LINE+3]]:5: Expected identifier after `.`. + // CHECK:STDERR: a.42; + // CHECK:STDERR: ^ a.42; } diff --git a/toolchain/parser/testdata/basics/fail_no_intro_with_semi.carbon b/toolchain/parser/testdata/basics/fail_no_intro_with_semi.carbon index b0739fa40f96..572e904d28f3 100644 --- a/toolchain/parser/testdata/basics/fail_no_intro_with_semi.carbon +++ b/toolchain/parser/testdata/basics/fail_no_intro_with_semi.carbon @@ -8,5 +8,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_no_intro_with_semi.carbon:[[@LINE+1]]:1: Unrecognized declaration introducer. +// CHECK:STDERR: fail_no_intro_with_semi.carbon:[[@LINE+3]]:1: Unrecognized declaration introducer. +// CHECK:STDERR: foo; +// CHECK:STDERR: ^ foo; diff --git a/toolchain/parser/testdata/basics/fail_no_intro_without_semi.carbon b/toolchain/parser/testdata/basics/fail_no_intro_without_semi.carbon index a75c063379eb..63cdf4da8c61 100644 --- a/toolchain/parser/testdata/basics/fail_no_intro_without_semi.carbon +++ b/toolchain/parser/testdata/basics/fail_no_intro_without_semi.carbon @@ -8,5 +8,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_no_intro_without_semi.carbon:[[@LINE+1]]:1: Unrecognized declaration introducer. +// CHECK:STDERR: fail_no_intro_without_semi.carbon:[[@LINE+3]]:1: Unrecognized declaration introducer. +// CHECK:STDERR: foo bar baz +// CHECK:STDERR: ^ foo bar baz diff --git a/toolchain/parser/testdata/basics/fail_paren_match_regression.carbon b/toolchain/parser/testdata/basics/fail_paren_match_regression.carbon index edb001686dcc..ab0b97cf001d 100644 --- a/toolchain/parser/testdata/basics/fail_paren_match_regression.carbon +++ b/toolchain/parser/testdata/basics/fail_paren_match_regression.carbon @@ -16,7 +16,13 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_paren_match_regression.carbon:[[@LINE+3]]:5: Expected pattern in `var` declaration. -// CHECK:STDERR: fail_paren_match_regression.carbon:[[@LINE+2]]:12: Expected `,` or `)`. -// CHECK:STDERR: fail_paren_match_regression.carbon:[[@LINE+1]]:15: `var` declarations must end with a `;`. +// CHECK:STDERR: fail_paren_match_regression.carbon:[[@LINE+9]]:5: Expected pattern in `var` declaration. +// CHECK:STDERR: var = (foo {}) +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_paren_match_regression.carbon:[[@LINE+6]]:12: Expected `,` or `)`. +// CHECK:STDERR: var = (foo {}) +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_paren_match_regression.carbon:[[@LINE+3]]:15: `var` declarations must end with a `;`. +// CHECK:STDERR: var = (foo {}) +// CHECK:STDERR: ^ var = (foo {}) diff --git a/toolchain/parser/testdata/for/fail_colon_instead_of_in.carbon b/toolchain/parser/testdata/for/fail_colon_instead_of_in.carbon index 364c61da218e..bbb593aa0a54 100644 --- a/toolchain/parser/testdata/for/fail_colon_instead_of_in.carbon +++ b/toolchain/parser/testdata/for/fail_colon_instead_of_in.carbon @@ -30,7 +30,9 @@ // CHECK:STDOUT: ] fn foo() { - // CHECK:STDERR: fail_colon_instead_of_in.carbon:[[@LINE+1]]:19: `:` should be replaced by `in`. + // CHECK:STDERR: fail_colon_instead_of_in.carbon:[[@LINE+3]]:19: `:` should be replaced by `in`. + // CHECK:STDERR: for (var x: i32 : y) { + // CHECK:STDERR: ^ for (var x: i32 : y) { Print(x); } diff --git a/toolchain/parser/testdata/for/fail_missing_in.carbon b/toolchain/parser/testdata/for/fail_missing_in.carbon index afc62fa04555..4161fcea4ebb 100644 --- a/toolchain/parser/testdata/for/fail_missing_in.carbon +++ b/toolchain/parser/testdata/for/fail_missing_in.carbon @@ -30,7 +30,9 @@ // CHECK:STDOUT: ] fn foo() { - // CHECK:STDERR: fail_missing_in.carbon:[[@LINE+1]]:19: Expected `in` after loop `var` declaration. + // CHECK:STDERR: fail_missing_in.carbon:[[@LINE+3]]:19: Expected `in` after loop `var` declaration. + // CHECK:STDERR: for (var x: i32 y) { + // CHECK:STDERR: ^ for (var x: i32 y) { Print(x); } diff --git a/toolchain/parser/testdata/for/fail_missing_var.carbon b/toolchain/parser/testdata/for/fail_missing_var.carbon index 7583e5f3e82e..b7a3a161f18d 100644 --- a/toolchain/parser/testdata/for/fail_missing_var.carbon +++ b/toolchain/parser/testdata/for/fail_missing_var.carbon @@ -25,7 +25,9 @@ // CHECK:STDOUT: ] fn foo() { - // CHECK:STDERR: fail_missing_var.carbon:[[@LINE+1]]:8: Expected `var` declaration. + // CHECK:STDERR: fail_missing_var.carbon:[[@LINE+3]]:8: Expected `var` declaration. + // CHECK:STDERR: for (x: i32 in y) { + // CHECK:STDERR: ^ for (x: i32 in y) { Print(x); } diff --git a/toolchain/parser/testdata/function/declaration/fail_identifier_instead_of_sig.carbon b/toolchain/parser/testdata/function/declaration/fail_identifier_instead_of_sig.carbon index 0be9c2c4175b..dab5d74d4a67 100644 --- a/toolchain/parser/testdata/function/declaration/fail_identifier_instead_of_sig.carbon +++ b/toolchain/parser/testdata/function/declaration/fail_identifier_instead_of_sig.carbon @@ -10,5 +10,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_identifier_instead_of_sig.carbon:[[@LINE+1]]:8: `fn` requires a `(` for parameters. +// CHECK:STDERR: fail_identifier_instead_of_sig.carbon:[[@LINE+3]]:8: `fn` requires a `(` for parameters. +// CHECK:STDERR: fn foo bar; +// CHECK:STDERR: ^ fn foo bar; diff --git a/toolchain/parser/testdata/function/declaration/fail_missing_deduced_close.carbon b/toolchain/parser/testdata/function/declaration/fail_missing_deduced_close.carbon index 4161287555b4..3ce17ed3d0b3 100644 --- a/toolchain/parser/testdata/function/declaration/fail_missing_deduced_close.carbon +++ b/toolchain/parser/testdata/function/declaration/fail_missing_deduced_close.carbon @@ -16,7 +16,13 @@ // CHECK:STDOUT: ] // Fix and uncomment this to test error handling. -// CHECK:STDERR: fail_missing_deduced_close.carbon:[[@LINE+2]]:7: Closing symbol does not match most recent opening symbol. -// CHECK:STDERR: fail_missing_deduced_close.carbon:[[@LINE+1]]:8: Expected parameter declaration. +// CHECK:STDERR: fail_missing_deduced_close.carbon:[[@LINE+9]]:7: Closing symbol does not match most recent opening symbol. +// CHECK:STDERR: fn Div[(); +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_missing_deduced_close.carbon:[[@LINE+6]]:8: Expected parameter declaration. +// CHECK:STDERR: fn Div[(); +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_missing_deduced_close.carbon:[[@LINE+3]]:11: A `(` for parameters is required after deduced parameters. +// CHECK:STDERR: fn Div[(); +// CHECK:STDERR: ^ fn Div[(); -// CHECK:STDERR: fail_missing_deduced_close.carbon:[[@LINE+0]]:127: A `(` for parameters is required after deduced parameters. diff --git a/toolchain/parser/testdata/function/declaration/fail_missing_name.carbon b/toolchain/parser/testdata/function/declaration/fail_missing_name.carbon index e448ab4d4eb3..773d1dd7e3a6 100644 --- a/toolchain/parser/testdata/function/declaration/fail_missing_name.carbon +++ b/toolchain/parser/testdata/function/declaration/fail_missing_name.carbon @@ -10,5 +10,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_missing_name.carbon:[[@LINE+1]]:4: `fn` introducer should be followed by a name. +// CHECK:STDERR: fail_missing_name.carbon:[[@LINE+3]]:4: `fn` introducer should be followed by a name. +// CHECK:STDERR: fn (); +// CHECK:STDERR: ^ fn (); diff --git a/toolchain/parser/testdata/function/declaration/fail_no_sig_or_semi.carbon b/toolchain/parser/testdata/function/declaration/fail_no_sig_or_semi.carbon index 7e31e3406c8d..0fea0e86bc54 100644 --- a/toolchain/parser/testdata/function/declaration/fail_no_sig_or_semi.carbon +++ b/toolchain/parser/testdata/function/declaration/fail_no_sig_or_semi.carbon @@ -10,5 +10,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_no_sig_or_semi.carbon:[[@LINE+1]]:7: `fn` requires a `(` for parameters. +// CHECK:STDERR: fail_no_sig_or_semi.carbon:[[@LINE+3]]:7: `fn` requires a `(` for parameters. +// CHECK:STDERR: fn foo +// CHECK:STDERR: ^ fn foo diff --git a/toolchain/parser/testdata/function/declaration/fail_only_fn_and_semi.carbon b/toolchain/parser/testdata/function/declaration/fail_only_fn_and_semi.carbon index b1697e36989a..340d33543f9e 100644 --- a/toolchain/parser/testdata/function/declaration/fail_only_fn_and_semi.carbon +++ b/toolchain/parser/testdata/function/declaration/fail_only_fn_and_semi.carbon @@ -10,5 +10,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_only_fn_and_semi.carbon:[[@LINE+1]]:3: `fn` introducer should be followed by a name. +// CHECK:STDERR: fail_only_fn_and_semi.carbon:[[@LINE+3]]:3: `fn` introducer should be followed by a name. +// CHECK:STDERR: fn; +// CHECK:STDERR: ^ fn; diff --git a/toolchain/parser/testdata/function/declaration/fail_repeated_fn_and_semi.carbon b/toolchain/parser/testdata/function/declaration/fail_repeated_fn_and_semi.carbon index 3bcab2dc76e5..f3245ea38c34 100644 --- a/toolchain/parser/testdata/function/declaration/fail_repeated_fn_and_semi.carbon +++ b/toolchain/parser/testdata/function/declaration/fail_repeated_fn_and_semi.carbon @@ -10,5 +10,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_repeated_fn_and_semi.carbon:[[@LINE+1]]:4: `fn` introducer should be followed by a name. +// CHECK:STDERR: fail_repeated_fn_and_semi.carbon:[[@LINE+3]]:4: `fn` introducer should be followed by a name. +// CHECK:STDERR: fn fn; +// CHECK:STDERR: ^ fn fn; diff --git a/toolchain/parser/testdata/function/declaration/fail_skip_indented_newline_until_outdent.carbon b/toolchain/parser/testdata/function/declaration/fail_skip_indented_newline_until_outdent.carbon index 248904cb4708..397cf8cab06b 100644 --- a/toolchain/parser/testdata/function/declaration/fail_skip_indented_newline_until_outdent.carbon +++ b/toolchain/parser/testdata/function/declaration/fail_skip_indented_newline_until_outdent.carbon @@ -15,7 +15,9 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] - // CHECK:STDERR: fail_skip_indented_newline_until_outdent.carbon:[[@LINE+1]]:6: `fn` introducer should be followed by a name. + // CHECK:STDERR: fail_skip_indented_newline_until_outdent.carbon:[[@LINE+3]]:6: `fn` introducer should be followed by a name. + // CHECK:STDERR: fn (x, + // CHECK:STDERR: ^ fn (x, y, z) diff --git a/toolchain/parser/testdata/function/declaration/fail_skip_indented_newline_with_semi.carbon b/toolchain/parser/testdata/function/declaration/fail_skip_indented_newline_with_semi.carbon index bcacfef68499..441e73eb45f5 100644 --- a/toolchain/parser/testdata/function/declaration/fail_skip_indented_newline_with_semi.carbon +++ b/toolchain/parser/testdata/function/declaration/fail_skip_indented_newline_with_semi.carbon @@ -15,7 +15,9 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_skip_indented_newline_with_semi.carbon:[[@LINE+1]]:4: `fn` introducer should be followed by a name. +// CHECK:STDERR: fail_skip_indented_newline_with_semi.carbon:[[@LINE+3]]:4: `fn` introducer should be followed by a name. +// CHECK:STDERR: fn (x, +// CHECK:STDERR: ^ fn (x, y, z); diff --git a/toolchain/parser/testdata/function/declaration/fail_skip_indented_newline_without_semi.carbon b/toolchain/parser/testdata/function/declaration/fail_skip_indented_newline_without_semi.carbon index 5551a423d4c0..75eff31c1cc6 100644 --- a/toolchain/parser/testdata/function/declaration/fail_skip_indented_newline_without_semi.carbon +++ b/toolchain/parser/testdata/function/declaration/fail_skip_indented_newline_without_semi.carbon @@ -15,7 +15,9 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_skip_indented_newline_without_semi.carbon:[[@LINE+1]]:4: `fn` introducer should be followed by a name. +// CHECK:STDERR: fail_skip_indented_newline_without_semi.carbon:[[@LINE+3]]:4: `fn` introducer should be followed by a name. +// CHECK:STDERR: fn (x, +// CHECK:STDERR: ^ fn (x, y, z) diff --git a/toolchain/parser/testdata/function/declaration/fail_skip_to_newline_without_semi.carbon b/toolchain/parser/testdata/function/declaration/fail_skip_to_newline_without_semi.carbon index 23bd0e4ad7be..7daf12a2a586 100644 --- a/toolchain/parser/testdata/function/declaration/fail_skip_to_newline_without_semi.carbon +++ b/toolchain/parser/testdata/function/declaration/fail_skip_to_newline_without_semi.carbon @@ -15,6 +15,8 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_skip_to_newline_without_semi.carbon:[[@LINE+1]]:4: `fn` introducer should be followed by a name. +// CHECK:STDERR: fail_skip_to_newline_without_semi.carbon:[[@LINE+3]]:4: `fn` introducer should be followed by a name. +// CHECK:STDERR: fn () +// CHECK:STDERR: ^ fn () fn F(); diff --git a/toolchain/parser/testdata/function/declaration/fail_skip_without_semi_to_curly.carbon b/toolchain/parser/testdata/function/declaration/fail_skip_without_semi_to_curly.carbon index c3e6c97649b9..87cbdcdf9155 100644 --- a/toolchain/parser/testdata/function/declaration/fail_skip_without_semi_to_curly.carbon +++ b/toolchain/parser/testdata/function/declaration/fail_skip_without_semi_to_curly.carbon @@ -13,6 +13,8 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_skip_without_semi_to_curly.carbon:[[@LINE+1]]:1: Unrecognized declaration introducer. +// CHECK:STDERR: fail_skip_without_semi_to_curly.carbon:[[@LINE+3]]:1: Unrecognized declaration introducer. +// CHECK:STDERR: struct X { fn () } +// CHECK:STDERR: ^ struct X { fn () } fn F(); diff --git a/toolchain/parser/testdata/function/declaration/fail_with_identifier_as_param.carbon b/toolchain/parser/testdata/function/declaration/fail_with_identifier_as_param.carbon index d9ef306d3aa9..c5652e521f96 100644 --- a/toolchain/parser/testdata/function/declaration/fail_with_identifier_as_param.carbon +++ b/toolchain/parser/testdata/function/declaration/fail_with_identifier_as_param.carbon @@ -15,5 +15,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_with_identifier_as_param.carbon:[[@LINE+1]]:11: Expected parameter declaration. +// CHECK:STDERR: fail_with_identifier_as_param.carbon:[[@LINE+3]]:11: Expected parameter declaration. +// CHECK:STDERR: fn foo(bar); +// CHECK:STDERR: ^ fn foo(bar); diff --git a/toolchain/parser/testdata/function/declaration/fail_without_name_and_many_tokens_in_params.carbon b/toolchain/parser/testdata/function/declaration/fail_without_name_and_many_tokens_in_params.carbon index 6202520595de..37801c760ea8 100644 --- a/toolchain/parser/testdata/function/declaration/fail_without_name_and_many_tokens_in_params.carbon +++ b/toolchain/parser/testdata/function/declaration/fail_without_name_and_many_tokens_in_params.carbon @@ -10,5 +10,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_without_name_and_many_tokens_in_params.carbon:[[@LINE+1]]:4: `fn` introducer should be followed by a name. +// CHECK:STDERR: fail_without_name_and_many_tokens_in_params.carbon:[[@LINE+3]]:4: `fn` introducer should be followed by a name. +// CHECK:STDERR: fn (a tokens c d e f g h i j k l m n o p q r s t u v w x y z); +// CHECK:STDERR: ^ fn (a tokens c d e f g h i j k l m n o p q r s t u v w x y z); diff --git a/toolchain/parser/testdata/function/definition/fail_identifier_in_statements.carbon b/toolchain/parser/testdata/function/definition/fail_identifier_in_statements.carbon index 12beb16bf27a..438bd7d4fda9 100644 --- a/toolchain/parser/testdata/function/definition/fail_identifier_in_statements.carbon +++ b/toolchain/parser/testdata/function/definition/fail_identifier_in_statements.carbon @@ -18,5 +18,7 @@ fn F() { // Note: this might become valid depending on the expression syntax. This test // shouldn't be taken as a sign it should remain invalid. bar -// CHECK:STDERR: fail_identifier_in_statements.carbon:[[@LINE+1]]:1: Expected `;` after expression statement. +// CHECK:STDERR: fail_identifier_in_statements.carbon:[[@LINE+3]]:1: Expected `;` after expression statement. +// CHECK:STDERR: } +// CHECK:STDERR: ^ } diff --git a/toolchain/parser/testdata/generics/deduced_params/fail_no_parens.carbon b/toolchain/parser/testdata/generics/deduced_params/fail_no_parens.carbon index 915e473ff7df..d679c683840e 100644 --- a/toolchain/parser/testdata/generics/deduced_params/fail_no_parens.carbon +++ b/toolchain/parser/testdata/generics/deduced_params/fail_no_parens.carbon @@ -33,14 +33,22 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_no_parens.carbon:[[@LINE+1]]:12: A `(` for parameters is required after deduced parameters. +// CHECK:STDERR: fail_no_parens.carbon:[[@LINE+3]]:12: A `(` for parameters is required after deduced parameters. +// CHECK:STDERR: class Foo[]; +// CHECK:STDERR: ^ class Foo[]; -// CHECK:STDERR: fail_no_parens.carbon:[[@LINE+1]]:18: A `(` for parameters is required after deduced parameters. +// CHECK:STDERR: fail_no_parens.carbon:[[@LINE+3]]:18: A `(` for parameters is required after deduced parameters. +// CHECK:STDERR: class Foo[a: i32]; +// CHECK:STDERR: ^ class Foo[a: i32]; -// CHECK:STDERR: fail_no_parens.carbon:[[@LINE+1]]:17: A `(` for parameters is required after deduced parameters. +// CHECK:STDERR: fail_no_parens.carbon:[[@LINE+3]]:17: A `(` for parameters is required after deduced parameters. +// CHECK:STDERR: interface Bar[] {} +// CHECK:STDERR: ^ interface Bar[] {} -// CHECK:STDERR: fail_no_parens.carbon:[[@LINE+1]]:23: A `(` for parameters is required after deduced parameters. +// CHECK:STDERR: fail_no_parens.carbon:[[@LINE+3]]:23: A `(` for parameters is required after deduced parameters. +// CHECK:STDERR: interface Bar[a: i32] {} +// CHECK:STDERR: ^ interface Bar[a: i32] {} diff --git a/toolchain/parser/testdata/generics/interface/fail_missing_name.carbon b/toolchain/parser/testdata/generics/interface/fail_missing_name.carbon index 35e0e55e73c0..c78979aa2c59 100644 --- a/toolchain/parser/testdata/generics/interface/fail_missing_name.carbon +++ b/toolchain/parser/testdata/generics/interface/fail_missing_name.carbon @@ -10,6 +10,8 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_missing_name.carbon:[[@LINE+1]]:11: `interface` introducer should be followed by a name. +// CHECK:STDERR: fail_missing_name.carbon:[[@LINE+3]]:11: `interface` introducer should be followed by a name. +// CHECK:STDERR: interface { +// CHECK:STDERR: ^ interface { } diff --git a/toolchain/parser/testdata/generics/interface/fail_missing_open_curly.carbon b/toolchain/parser/testdata/generics/interface/fail_missing_open_curly.carbon index f7a58cef1535..5ce2a874480e 100644 --- a/toolchain/parser/testdata/generics/interface/fail_missing_open_curly.carbon +++ b/toolchain/parser/testdata/generics/interface/fail_missing_open_curly.carbon @@ -13,8 +13,12 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_missing_open_curly.carbon:[[@LINE+1]]:15: `interface` declarations must either end with a `;` or have a `{ ... }` block for a definition. +// CHECK:STDERR: fail_missing_open_curly.carbon:[[@LINE+3]]:15: `interface` declarations must either end with a `;` or have a `{ ... }` block for a definition. +// CHECK:STDERR: interface Bar Baz {} +// CHECK:STDERR: ^ interface Bar Baz {} -// CHECK:STDERR: fail_missing_open_curly.carbon:[[@LINE+1]]:14: `interface` declarations must either end with a `;` or have a `{ ... }` block for a definition. +// CHECK:STDERR: fail_missing_open_curly.carbon:[[@LINE+3]]:14: `interface` declarations must either end with a `;` or have a `{ ... }` block for a definition. +// CHECK:STDERR: interface Foo +// CHECK:STDERR: ^ interface Foo diff --git a/toolchain/parser/testdata/generics/interface/fail_no_impl_allowed.carbon b/toolchain/parser/testdata/generics/interface/fail_no_impl_allowed.carbon index bfbfb99b5c08..d21999b6ec62 100644 --- a/toolchain/parser/testdata/generics/interface/fail_no_impl_allowed.carbon +++ b/toolchain/parser/testdata/generics/interface/fail_no_impl_allowed.carbon @@ -27,7 +27,9 @@ // CHECK:STDOUT: ] interface Foo { - // CHECK:STDERR: fail_no_impl_allowed.carbon:[[@LINE+1]]:39: Method implementations are not allowed in interfaces. + // CHECK:STDERR: fail_no_impl_allowed.carbon:[[@LINE+3]]:39: Method implementations are not allowed in interfaces. + // CHECK:STDERR: fn Add[self: Self](b: Self) -> Self { + // CHECK:STDERR: ^ fn Add[self: Self](b: Self) -> Self { print("You can't do that."); } diff --git a/toolchain/parser/testdata/generics/interface/fail_self_param_syntax.carbon b/toolchain/parser/testdata/generics/interface/fail_self_param_syntax.carbon index d96e5e21361f..e406f524635f 100644 --- a/toolchain/parser/testdata/generics/interface/fail_self_param_syntax.carbon +++ b/toolchain/parser/testdata/generics/interface/fail_self_param_syntax.carbon @@ -42,9 +42,13 @@ // CHECK:STDOUT: ] interface Foo { - // CHECK:STDERR: fail_self_param_syntax.carbon:[[@LINE+1]]:13: Expected parameter declaration. + // CHECK:STDERR: fail_self_param_syntax.carbon:[[@LINE+3]]:13: Expected parameter declaration. + // CHECK:STDERR: fn Sub[me Self](b: Self) -> Self; + // CHECK:STDERR: ^ fn Sub[me Self](b: Self) -> Self; - // CHECK:STDERR: fail_self_param_syntax.carbon:[[@LINE+1]]:10: Expected parameter declaration. + // CHECK:STDERR: fail_self_param_syntax.carbon:[[@LINE+3]]:10: Expected parameter declaration. + // CHECK:STDERR: fn Mul[Self](b: Self) -> Self; + // CHECK:STDERR: ^ fn Mul[Self](b: Self) -> Self; } diff --git a/toolchain/parser/testdata/generics/named_constraint/fail_no_impl_allowed.carbon b/toolchain/parser/testdata/generics/named_constraint/fail_no_impl_allowed.carbon index 445d9aa054e6..024f69353752 100644 --- a/toolchain/parser/testdata/generics/named_constraint/fail_no_impl_allowed.carbon +++ b/toolchain/parser/testdata/generics/named_constraint/fail_no_impl_allowed.carbon @@ -27,6 +27,8 @@ // CHECK:STDOUT: ] constraint Foo { - // CHECK:STDERR: fail_no_impl_allowed.carbon:[[@LINE+1]]:39: Method implementations are not allowed in interfaces. + // CHECK:STDERR: fail_no_impl_allowed.carbon:[[@LINE+3]]:39: Method implementations are not allowed in interfaces. + // CHECK:STDERR: fn Add[self: Self](b: Self) -> Self {} + // CHECK:STDERR: ^ fn Add[self: Self](b: Self) -> Self {} } diff --git a/toolchain/parser/testdata/if/fail_else_unbraced.carbon b/toolchain/parser/testdata/if/fail_else_unbraced.carbon index 822d0c13c5b7..25593f190bb6 100644 --- a/toolchain/parser/testdata/if/fail_else_unbraced.carbon +++ b/toolchain/parser/testdata/if/fail_else_unbraced.carbon @@ -61,15 +61,23 @@ fn F() { if (a) - // CHECK:STDERR: fail_else_unbraced.carbon:[[@LINE+1]]:5: Expected braced code block. + // CHECK:STDERR: fail_else_unbraced.carbon:[[@LINE+3]]:5: Expected braced code block. + // CHECK:STDERR: if (b) + // CHECK:STDERR: ^ if (b) - // CHECK:STDERR: fail_else_unbraced.carbon:[[@LINE+1]]:7: Expected braced code block. + // CHECK:STDERR: fail_else_unbraced.carbon:[[@LINE+3]]:7: Expected braced code block. + // CHECK:STDERR: c; + // CHECK:STDERR: ^ c; else - // CHECK:STDERR: fail_else_unbraced.carbon:[[@LINE+1]]:7: Expected braced code block. + // CHECK:STDERR: fail_else_unbraced.carbon:[[@LINE+3]]:7: Expected braced code block. + // CHECK:STDERR: d; + // CHECK:STDERR: ^ d; else - // CHECK:STDERR: fail_else_unbraced.carbon:[[@LINE+1]]:5: Expected braced code block. + // CHECK:STDERR: fail_else_unbraced.carbon:[[@LINE+3]]:5: Expected braced code block. + // CHECK:STDERR: e; + // CHECK:STDERR: ^ e; if (x) { f; } else if (x) { g; } diff --git a/toolchain/parser/testdata/if/fail_errors.carbon b/toolchain/parser/testdata/if/fail_errors.carbon index 41bfaeadaeab..723d6e258c51 100644 --- a/toolchain/parser/testdata/if/fail_errors.carbon +++ b/toolchain/parser/testdata/if/fail_errors.carbon @@ -39,13 +39,23 @@ // CHECK:STDOUT: ] fn F() { - // CHECK:STDERR: fail_errors.carbon:[[@LINE+1]]:6: Expected `(` after `if`. + // CHECK:STDERR: fail_errors.carbon:[[@LINE+3]]:6: Expected `(` after `if`. + // CHECK:STDERR: if a {} + // CHECK:STDERR: ^ if a {} - // CHECK:STDERR: fail_errors.carbon:[[@LINE+1]]:7: Expected expression. + // CHECK:STDERR: fail_errors.carbon:[[@LINE+3]]:7: Expected expression. + // CHECK:STDERR: if () {} + // CHECK:STDERR: ^ if () {} - // CHECK:STDERR: fail_errors.carbon:[[@LINE+1]]:9: Unexpected tokens before `)`. + // CHECK:STDERR: fail_errors.carbon:[[@LINE+3]]:9: Unexpected tokens before `)`. + // CHECK:STDERR: if (b c) {} + // CHECK:STDERR: ^ if (b c) {} if (d) -// CHECK:STDERR: fail_errors.carbon:[[@LINE+2]]:1: Expected braced code block. -// CHECK:STDERR: fail_errors.carbon:[[@LINE+1]]:1: Expected expression. +// CHECK:STDERR: fail_errors.carbon:[[@LINE+6]]:1: Expected braced code block. +// CHECK:STDERR: } +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_errors.carbon:[[@LINE+3]]:1: Expected expression. +// CHECK:STDERR: } +// CHECK:STDERR: ^ } diff --git a/toolchain/parser/testdata/if/fail_unbraced.carbon b/toolchain/parser/testdata/if/fail_unbraced.carbon index f09ac6c79251..fd14d7dbbc84 100644 --- a/toolchain/parser/testdata/if/fail_unbraced.carbon +++ b/toolchain/parser/testdata/if/fail_unbraced.carbon @@ -36,10 +36,16 @@ fn F() { if (a) - // CHECK:STDERR: fail_unbraced.carbon:[[@LINE+1]]:5: Expected braced code block. + // CHECK:STDERR: fail_unbraced.carbon:[[@LINE+3]]:5: Expected braced code block. + // CHECK:STDERR: if (b) + // CHECK:STDERR: ^ if (b) - // CHECK:STDERR: fail_unbraced.carbon:[[@LINE+1]]:7: Expected braced code block. + // CHECK:STDERR: fail_unbraced.carbon:[[@LINE+3]]:7: Expected braced code block. + // CHECK:STDERR: if (c) + // CHECK:STDERR: ^ if (c) - // CHECK:STDERR: fail_unbraced.carbon:[[@LINE+1]]:9: Expected braced code block. + // CHECK:STDERR: fail_unbraced.carbon:[[@LINE+3]]:9: Expected braced code block. + // CHECK:STDERR: d; + // CHECK:STDERR: ^ d; } diff --git a/toolchain/parser/testdata/if_expression/fail_condition_missing.carbon b/toolchain/parser/testdata/if_expression/fail_condition_missing.carbon index d2bfcef83d47..02652411c05e 100644 --- a/toolchain/parser/testdata/if_expression/fail_condition_missing.carbon +++ b/toolchain/parser/testdata/if_expression/fail_condition_missing.carbon @@ -25,6 +25,8 @@ // CHECK:STDOUT: ] fn F() { - // CHECK:STDERR: fail_condition_missing.carbon:[[@LINE+1]]:18: Expected expression. + // CHECK:STDERR: fail_condition_missing.carbon:[[@LINE+3]]:18: Expected expression. + // CHECK:STDERR: var n: i32 = if; + // CHECK:STDERR: ^ var n: i32 = if; } diff --git a/toolchain/parser/testdata/if_expression/fail_else_expr_missing.carbon b/toolchain/parser/testdata/if_expression/fail_else_expr_missing.carbon index 550cc1680908..9f7a4f5c86fc 100644 --- a/toolchain/parser/testdata/if_expression/fail_else_expr_missing.carbon +++ b/toolchain/parser/testdata/if_expression/fail_else_expr_missing.carbon @@ -26,6 +26,8 @@ // CHECK:STDOUT: ] fn F() { - // CHECK:STDERR: fail_else_expr_missing.carbon:[[@LINE+1]]:35: Expected expression. + // CHECK:STDERR: fail_else_expr_missing.carbon:[[@LINE+3]]:35: Expected expression. + // CHECK:STDERR: var n: i32 = if true then 1 else; + // CHECK:STDERR: ^ var n: i32 = if true then 1 else; } diff --git a/toolchain/parser/testdata/if_expression/fail_else_missing.carbon b/toolchain/parser/testdata/if_expression/fail_else_missing.carbon index 790013b005f7..3734c06b6b38 100644 --- a/toolchain/parser/testdata/if_expression/fail_else_missing.carbon +++ b/toolchain/parser/testdata/if_expression/fail_else_missing.carbon @@ -26,6 +26,8 @@ // CHECK:STDOUT: ] fn F() { - // CHECK:STDERR: fail_else_missing.carbon:[[@LINE+1]]:30: Expected `else` after `if ... then ...`. + // CHECK:STDERR: fail_else_missing.carbon:[[@LINE+3]]:30: Expected `else` after `if ... then ...`. + // CHECK:STDERR: var n: i32 = if true then 1; + // CHECK:STDERR: ^ var n: i32 = if true then 1; } diff --git a/toolchain/parser/testdata/if_expression/fail_then_expr_missing.carbon b/toolchain/parser/testdata/if_expression/fail_then_expr_missing.carbon index d0afb92c5c53..74afc844d95a 100644 --- a/toolchain/parser/testdata/if_expression/fail_then_expr_missing.carbon +++ b/toolchain/parser/testdata/if_expression/fail_then_expr_missing.carbon @@ -26,6 +26,8 @@ // CHECK:STDOUT: ] fn F() { - // CHECK:STDERR: fail_then_expr_missing.carbon:[[@LINE+1]]:28: Expected expression. + // CHECK:STDERR: fail_then_expr_missing.carbon:[[@LINE+3]]:28: Expected expression. + // CHECK:STDERR: var n: i32 = if true then; + // CHECK:STDERR: ^ var n: i32 = if true then; } diff --git a/toolchain/parser/testdata/if_expression/fail_then_missing.carbon b/toolchain/parser/testdata/if_expression/fail_then_missing.carbon index c79677c8332f..047f4d9ab089 100644 --- a/toolchain/parser/testdata/if_expression/fail_then_missing.carbon +++ b/toolchain/parser/testdata/if_expression/fail_then_missing.carbon @@ -25,6 +25,8 @@ // CHECK:STDOUT: ] fn F() { - // CHECK:STDERR: fail_then_missing.carbon:[[@LINE+1]]:23: Expected `then` after `if` condition. + // CHECK:STDERR: fail_then_missing.carbon:[[@LINE+3]]:23: Expected `then` after `if` condition. + // CHECK:STDERR: var n: i32 = if true; + // CHECK:STDERR: ^ var n: i32 = if true; } diff --git a/toolchain/parser/testdata/if_expression/fail_top_level_if.carbon b/toolchain/parser/testdata/if_expression/fail_top_level_if.carbon index efbd138742a2..97fa56d76991 100644 --- a/toolchain/parser/testdata/if_expression/fail_top_level_if.carbon +++ b/toolchain/parser/testdata/if_expression/fail_top_level_if.carbon @@ -22,8 +22,14 @@ // CHECK:STDOUT: ] fn F() { - // CHECK:STDERR: fail_top_level_if.carbon:[[@LINE+3]]:6: Expected `(` after `if`. - // CHECK:STDERR: fail_top_level_if.carbon:[[@LINE+2]]:11: Expected braced code block. - // CHECK:STDERR: fail_top_level_if.carbon:[[@LINE+1]]:11: Expected expression. + // CHECK:STDERR: fail_top_level_if.carbon:[[@LINE+9]]:6: Expected `(` after `if`. + // CHECK:STDERR: if true then 1 else 2; + // CHECK:STDERR: ^ + // CHECK:STDERR: fail_top_level_if.carbon:[[@LINE+6]]:11: Expected braced code block. + // CHECK:STDERR: if true then 1 else 2; + // CHECK:STDERR: ^ + // CHECK:STDERR: fail_top_level_if.carbon:[[@LINE+3]]:11: Expected expression. + // CHECK:STDERR: if true then 1 else 2; + // CHECK:STDERR: ^ if true then 1 else 2; } diff --git a/toolchain/parser/testdata/namespace/fail_args.carbon b/toolchain/parser/testdata/namespace/fail_args.carbon index c7397a5e02b7..b792a9874627 100644 --- a/toolchain/parser/testdata/namespace/fail_args.carbon +++ b/toolchain/parser/testdata/namespace/fail_args.carbon @@ -10,5 +10,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_args.carbon:[[@LINE+1]]:14: `namespace` declarations must end with a `;`. +// CHECK:STDERR: fail_args.carbon:[[@LINE+3]]:14: `namespace` declarations must end with a `;`. +// CHECK:STDERR: namespace Foo(); +// CHECK:STDERR: ^ namespace Foo(); diff --git a/toolchain/parser/testdata/namespace/fail_incomplete_name.carbon b/toolchain/parser/testdata/namespace/fail_incomplete_name.carbon index 2805a27238a0..6fb7f4b36660 100644 --- a/toolchain/parser/testdata/namespace/fail_incomplete_name.carbon +++ b/toolchain/parser/testdata/namespace/fail_incomplete_name.carbon @@ -12,5 +12,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_incomplete_name.carbon:[[@LINE+1]]:15: Expected identifier after `.`. +// CHECK:STDERR: fail_incomplete_name.carbon:[[@LINE+3]]:15: Expected identifier after `.`. +// CHECK:STDERR: namespace Foo.; +// CHECK:STDERR: ^ namespace Foo.; diff --git a/toolchain/parser/testdata/namespace/fail_no_name.carbon b/toolchain/parser/testdata/namespace/fail_no_name.carbon index 5b98ad97c886..a64f3c9e54be 100644 --- a/toolchain/parser/testdata/namespace/fail_no_name.carbon +++ b/toolchain/parser/testdata/namespace/fail_no_name.carbon @@ -10,5 +10,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_no_name.carbon:[[@LINE+1]]:10: `namespace` introducer should be followed by a name. +// CHECK:STDERR: fail_no_name.carbon:[[@LINE+3]]:10: `namespace` introducer should be followed by a name. +// CHECK:STDERR: namespace; +// CHECK:STDERR: ^ namespace; diff --git a/toolchain/parser/testdata/operators/fail_infix_uneven_space_after.carbon b/toolchain/parser/testdata/operators/fail_infix_uneven_space_after.carbon index bf4cb93f8ca5..5e6b28ae884a 100644 --- a/toolchain/parser/testdata/operators/fail_infix_uneven_space_after.carbon +++ b/toolchain/parser/testdata/operators/fail_infix_uneven_space_after.carbon @@ -17,5 +17,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+1]]:16: `var` declarations must end with a `;`. +// CHECK:STDERR: fail_infix_uneven_space_after.carbon:[[@LINE+3]]:16: `var` declarations must end with a `;`. +// CHECK:STDERR: var n: i8 = n* n; +// CHECK:STDERR: ^ var n: i8 = n* n; diff --git a/toolchain/parser/testdata/operators/fail_invalid_infix.carbon b/toolchain/parser/testdata/operators/fail_invalid_infix.carbon index cd8e07fb7e18..aa8487d9ffec 100644 --- a/toolchain/parser/testdata/operators/fail_invalid_infix.carbon +++ b/toolchain/parser/testdata/operators/fail_invalid_infix.carbon @@ -34,10 +34,18 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_invalid_infix.carbon:[[@LINE+1]]:19: Expected expression. +// CHECK:STDERR: fail_invalid_infix.carbon:[[@LINE+3]]:19: Expected expression. +// CHECK:STDERR: var a: i32 = n == ; +// CHECK:STDERR: ^ var a: i32 = n == ; -// CHECK:STDERR: fail_invalid_infix.carbon:[[@LINE+1]]:14: Expected expression. +// CHECK:STDERR: fail_invalid_infix.carbon:[[@LINE+3]]:14: Expected expression. +// CHECK:STDERR: var b: i32 = == n; +// CHECK:STDERR: ^ var b: i32 = == n; -// CHECK:STDERR: fail_invalid_infix.carbon:[[@LINE+2]]:14: Expected expression. -// CHECK:STDERR: fail_invalid_infix.carbon:[[@LINE+1]]:17: Expected expression. +// CHECK:STDERR: fail_invalid_infix.carbon:[[@LINE+6]]:14: Expected expression. +// CHECK:STDERR: var c: i32 = == ; +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_invalid_infix.carbon:[[@LINE+3]]:17: Expected expression. +// CHECK:STDERR: var c: i32 = == ; +// CHECK:STDERR: ^ var c: i32 = == ; diff --git a/toolchain/parser/testdata/operators/fail_precedence_and_or.carbon b/toolchain/parser/testdata/operators/fail_precedence_and_or.carbon index 3102aaf4cff8..5ad06b232ea8 100644 --- a/toolchain/parser/testdata/operators/fail_precedence_and_or.carbon +++ b/toolchain/parser/testdata/operators/fail_precedence_and_or.carbon @@ -22,6 +22,8 @@ // CHECK:STDOUT: ] fn F() { - // CHECK:STDERR: fail_precedence_and_or.carbon:[[@LINE+1]]:11: Parentheses are required to disambiguate operator precedence. + // CHECK:STDERR: fail_precedence_and_or.carbon:[[@LINE+3]]:11: Parentheses are required to disambiguate operator precedence. + // CHECK:STDERR: a and b or c; + // CHECK:STDERR: ^ a and b or c; } diff --git a/toolchain/parser/testdata/operators/fail_precedence_or_and.carbon b/toolchain/parser/testdata/operators/fail_precedence_or_and.carbon index c17dbbe82a07..dd44053fd293 100644 --- a/toolchain/parser/testdata/operators/fail_precedence_or_and.carbon +++ b/toolchain/parser/testdata/operators/fail_precedence_or_and.carbon @@ -22,6 +22,8 @@ // CHECK:STDOUT: ] fn F() { - // CHECK:STDERR: fail_precedence_or_and.carbon:[[@LINE+1]]:10: Parentheses are required to disambiguate operator precedence. + // CHECK:STDERR: fail_precedence_or_and.carbon:[[@LINE+3]]:10: Parentheses are required to disambiguate operator precedence. + // CHECK:STDERR: a or b and c; + // CHECK:STDERR: ^ a or b and c; } diff --git a/toolchain/parser/testdata/operators/fail_precedence_star_minus.carbon b/toolchain/parser/testdata/operators/fail_precedence_star_minus.carbon index 8eb11a41fd04..7ea35567c5af 100644 --- a/toolchain/parser/testdata/operators/fail_precedence_star_minus.carbon +++ b/toolchain/parser/testdata/operators/fail_precedence_star_minus.carbon @@ -17,5 +17,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_precedence_star_minus.carbon:[[@LINE+1]]:16: Parentheses are required to disambiguate operator precedence. +// CHECK:STDERR: fail_precedence_star_minus.carbon:[[@LINE+3]]:16: Parentheses are required to disambiguate operator precedence. +// CHECK:STDERR: var n: i8 = n* -n; +// CHECK:STDERR: ^ var n: i8 = n* -n; diff --git a/toolchain/parser/testdata/operators/fail_precedence_star_star.carbon b/toolchain/parser/testdata/operators/fail_precedence_star_star.carbon index 3a25e158cba4..fa343e231174 100644 --- a/toolchain/parser/testdata/operators/fail_precedence_star_star.carbon +++ b/toolchain/parser/testdata/operators/fail_precedence_star_star.carbon @@ -17,5 +17,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_precedence_star_star.carbon:[[@LINE+1]]:16: Parentheses are required to disambiguate operator precedence. +// CHECK:STDERR: fail_precedence_star_star.carbon:[[@LINE+3]]:16: Parentheses are required to disambiguate operator precedence. +// CHECK:STDERR: var n: i8 = n* *p; +// CHECK:STDERR: ^ var n: i8 = n* *p; diff --git a/toolchain/parser/testdata/operators/fail_star_star_no_space.carbon b/toolchain/parser/testdata/operators/fail_star_star_no_space.carbon index ae1990861014..23ae11aa1229 100644 --- a/toolchain/parser/testdata/operators/fail_star_star_no_space.carbon +++ b/toolchain/parser/testdata/operators/fail_star_star_no_space.carbon @@ -20,5 +20,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+1]]:16: `var` declarations must end with a `;`. +// CHECK:STDERR: fail_star_star_no_space.carbon:[[@LINE+3]]:16: `var` declarations must end with a `;`. +// CHECK:STDERR: var n: i8 = n**p; +// CHECK:STDERR: ^ var n: i8 = n**p; diff --git a/toolchain/parser/testdata/operators/fail_variety.carbon b/toolchain/parser/testdata/operators/fail_variety.carbon index 269b1e87b4c8..eeae94c21201 100644 --- a/toolchain/parser/testdata/operators/fail_variety.carbon +++ b/toolchain/parser/testdata/operators/fail_variety.carbon @@ -35,9 +35,17 @@ // CHECK:STDOUT: ] fn F() { - // CHECK:STDERR: fail_variety.carbon:[[@LINE+4]]:29: Parentheses are required to disambiguate operator precedence. - // CHECK:STDERR: fail_variety.carbon:[[@LINE+3]]:34: Parentheses are required to disambiguate operator precedence. - // CHECK:STDERR: fail_variety.carbon:[[@LINE+2]]:38: Parentheses are required to disambiguate operator precedence. - // CHECK:STDERR: fail_variety.carbon:[[@LINE+1]]:40: Parentheses are required to disambiguate operator precedence. + // CHECK:STDERR: fail_variety.carbon:[[@LINE+12]]:29: Parentheses are required to disambiguate operator precedence. + // CHECK:STDERR: n = a * b + c * d = d * d << e & f - not g; + // CHECK:STDERR: ^ + // CHECK:STDERR: fail_variety.carbon:[[@LINE+9]]:34: Parentheses are required to disambiguate operator precedence. + // CHECK:STDERR: n = a * b + c * d = d * d << e & f - not g; + // CHECK:STDERR: ^ + // CHECK:STDERR: fail_variety.carbon:[[@LINE+6]]:38: Parentheses are required to disambiguate operator precedence. + // CHECK:STDERR: n = a * b + c * d = d * d << e & f - not g; + // CHECK:STDERR: ^ + // CHECK:STDERR: fail_variety.carbon:[[@LINE+3]]:40: Parentheses are required to disambiguate operator precedence. + // 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; } diff --git a/toolchain/parser/testdata/operators/recover_infix_uneven_space_before.carbon b/toolchain/parser/testdata/operators/recover_infix_uneven_space_before.carbon index 27341a6b9470..c28c99d7949c 100644 --- a/toolchain/parser/testdata/operators/recover_infix_uneven_space_before.carbon +++ b/toolchain/parser/testdata/operators/recover_infix_uneven_space_before.carbon @@ -16,5 +16,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: recover_infix_uneven_space_before.carbon:[[@LINE+1]]:15: Whitespace missing after binary operator. +// CHECK:STDERR: recover_infix_uneven_space_before.carbon:[[@LINE+3]]:15: Whitespace missing after binary operator. +// CHECK:STDERR: var n: i8 = n *n; +// CHECK:STDERR: ^ var n: i8 = n *n; diff --git a/toolchain/parser/testdata/operators/recover_postfix_space.carbon b/toolchain/parser/testdata/operators/recover_postfix_space.carbon index 0fb07390dc8e..9ce93aeb2f35 100644 --- a/toolchain/parser/testdata/operators/recover_postfix_space.carbon +++ b/toolchain/parser/testdata/operators/recover_postfix_space.carbon @@ -15,5 +15,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: recover_postfix_space.carbon:[[@LINE+1]]:18: Whitespace is not allowed before this unary operator. +// CHECK:STDERR: recover_postfix_space.carbon:[[@LINE+3]]:18: Whitespace is not allowed before this unary operator. +// CHECK:STDERR: var v: type = i8 *; +// CHECK:STDERR: ^ var v: type = i8 *; diff --git a/toolchain/parser/testdata/operators/recover_postfix_space_before_comma.carbon b/toolchain/parser/testdata/operators/recover_postfix_space_before_comma.carbon index 2a4920403696..5660ce7658c6 100644 --- a/toolchain/parser/testdata/operators/recover_postfix_space_before_comma.carbon +++ b/toolchain/parser/testdata/operators/recover_postfix_space_before_comma.carbon @@ -20,5 +20,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: recover_postfix_space_before_comma.carbon:[[@LINE+1]]:18: Whitespace is not allowed before this unary operator. +// CHECK:STDERR: recover_postfix_space_before_comma.carbon:[[@LINE+3]]:18: Whitespace is not allowed before this unary operator. +// CHECK:STDERR: var n: i8 = F(i8 *, 0); +// CHECK:STDERR: ^ var n: i8 = F(i8 *, 0); diff --git a/toolchain/parser/testdata/operators/recover_postfix_space_in_call.carbon b/toolchain/parser/testdata/operators/recover_postfix_space_in_call.carbon index 8738049a49f3..a4591465524f 100644 --- a/toolchain/parser/testdata/operators/recover_postfix_space_in_call.carbon +++ b/toolchain/parser/testdata/operators/recover_postfix_space_in_call.carbon @@ -18,5 +18,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: recover_postfix_space_in_call.carbon:[[@LINE+1]]:18: Whitespace is not allowed before this unary operator. +// CHECK:STDERR: recover_postfix_space_in_call.carbon:[[@LINE+3]]:18: Whitespace is not allowed before this unary operator. +// CHECK:STDERR: var n: i8 = F(i8 *); +// CHECK:STDERR: ^ var n: i8 = F(i8 *); diff --git a/toolchain/parser/testdata/operators/recover_postfix_space_surrounding.carbon b/toolchain/parser/testdata/operators/recover_postfix_space_surrounding.carbon index 02e24232c98e..26f64d176d2f 100644 --- a/toolchain/parser/testdata/operators/recover_postfix_space_surrounding.carbon +++ b/toolchain/parser/testdata/operators/recover_postfix_space_surrounding.carbon @@ -15,5 +15,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: recover_postfix_space_surrounding.carbon:[[@LINE+1]]:18: Whitespace is not allowed before this unary operator. +// CHECK:STDERR: recover_postfix_space_surrounding.carbon:[[@LINE+3]]:18: Whitespace is not allowed before this unary operator. +// CHECK:STDERR: var v: type = i8 * ; +// CHECK:STDERR: ^ var v: type = i8 * ; diff --git a/toolchain/parser/testdata/operators/recover_prefix_space.carbon b/toolchain/parser/testdata/operators/recover_prefix_space.carbon index ac1a8277d776..8401fc2a1716 100644 --- a/toolchain/parser/testdata/operators/recover_prefix_space.carbon +++ b/toolchain/parser/testdata/operators/recover_prefix_space.carbon @@ -15,5 +15,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: recover_prefix_space.carbon:[[@LINE+1]]:13: Whitespace is not allowed after this unary operator. +// CHECK:STDERR: recover_prefix_space.carbon:[[@LINE+3]]:13: Whitespace is not allowed after this unary operator. +// CHECK:STDERR: var n: i8 = - n; +// CHECK:STDERR: ^ var n: i8 = - n; diff --git a/toolchain/parser/testdata/operators/recover_prefix_uneven_space_with_assign.carbon b/toolchain/parser/testdata/operators/recover_prefix_uneven_space_with_assign.carbon index 85ff8f790747..40e025be04d1 100644 --- a/toolchain/parser/testdata/operators/recover_prefix_uneven_space_with_assign.carbon +++ b/toolchain/parser/testdata/operators/recover_prefix_uneven_space_with_assign.carbon @@ -15,5 +15,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: recover_prefix_uneven_space_with_assign.carbon:[[@LINE+1]]:12: Whitespace is not allowed after this unary operator. +// CHECK:STDERR: recover_prefix_uneven_space_with_assign.carbon:[[@LINE+3]]:12: Whitespace is not allowed after this unary operator. +// CHECK:STDERR: var n: i8 =- n; +// CHECK:STDERR: ^ var n: i8 =- n; diff --git a/toolchain/parser/testdata/package/fail_extra_string.carbon b/toolchain/parser/testdata/package/fail_extra_string.carbon index 5bb6fe2b7091..c85a327a00d4 100644 --- a/toolchain/parser/testdata/package/fail_extra_string.carbon +++ b/toolchain/parser/testdata/package/fail_extra_string.carbon @@ -12,5 +12,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_extra_string.carbon:[[@LINE+1]]:27: Expected a `api` or `impl`. +// CHECK:STDERR: fail_extra_string.carbon:[[@LINE+3]]:27: Expected a `api` or `impl`. +// CHECK:STDERR: package Foo library "bar" "baz"; +// CHECK:STDERR: ^ package Foo library "bar" "baz"; diff --git a/toolchain/parser/testdata/package/fail_library_is_identifier.carbon b/toolchain/parser/testdata/package/fail_library_is_identifier.carbon index ca30015f7ee6..5959ab657b40 100644 --- a/toolchain/parser/testdata/package/fail_library_is_identifier.carbon +++ b/toolchain/parser/testdata/package/fail_library_is_identifier.carbon @@ -10,5 +10,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_library_is_identifier.carbon:[[@LINE+1]]:26: Expected a string literal to specify the library name. +// CHECK:STDERR: fail_library_is_identifier.carbon:[[@LINE+3]]:26: Expected a string literal to specify the library name. +// CHECK:STDERR: package Geometry library Shapes api; +// CHECK:STDERR: ^ package Geometry library Shapes api; diff --git a/toolchain/parser/testdata/package/fail_library_skips_name.carbon b/toolchain/parser/testdata/package/fail_library_skips_name.carbon index acf1bf82777c..cdbf0e26130e 100644 --- a/toolchain/parser/testdata/package/fail_library_skips_name.carbon +++ b/toolchain/parser/testdata/package/fail_library_skips_name.carbon @@ -9,5 +9,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_library_skips_name.carbon:[[@LINE+1]]:9: Expected identifier after `package`. +// CHECK:STDERR: fail_library_skips_name.carbon:[[@LINE+3]]:9: Expected identifier after `package`. +// CHECK:STDERR: package library "Shapes" api; +// CHECK:STDERR: ^ package library "Shapes" api; diff --git a/toolchain/parser/testdata/package/fail_name_is_keyword.carbon b/toolchain/parser/testdata/package/fail_name_is_keyword.carbon index aef11828990b..fc8f832737fa 100644 --- a/toolchain/parser/testdata/package/fail_name_is_keyword.carbon +++ b/toolchain/parser/testdata/package/fail_name_is_keyword.carbon @@ -9,5 +9,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_name_is_keyword.carbon:[[@LINE+1]]:9: Expected identifier after `package`. +// CHECK:STDERR: fail_name_is_keyword.carbon:[[@LINE+3]]:9: Expected identifier after `package`. +// CHECK:STDERR: package fn; +// CHECK:STDERR: ^ package fn; diff --git a/toolchain/parser/testdata/package/fail_no_name.carbon b/toolchain/parser/testdata/package/fail_no_name.carbon index 4a29360ff8b3..1a4cf0e7c429 100644 --- a/toolchain/parser/testdata/package/fail_no_name.carbon +++ b/toolchain/parser/testdata/package/fail_no_name.carbon @@ -9,5 +9,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_no_name.carbon:[[@LINE+1]]:8: Expected identifier after `package`. +// CHECK:STDERR: fail_no_name.carbon:[[@LINE+3]]:8: Expected identifier after `package`. +// CHECK:STDERR: package; +// CHECK:STDERR: ^ package; diff --git a/toolchain/parser/testdata/package/fail_no_semi.carbon b/toolchain/parser/testdata/package/fail_no_semi.carbon index 7f52f5a005f0..d740fd59b8ac 100644 --- a/toolchain/parser/testdata/package/fail_no_semi.carbon +++ b/toolchain/parser/testdata/package/fail_no_semi.carbon @@ -11,5 +11,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_no_semi.carbon:[[@LINE+1]]:21: `package` declarations must end with a `;`. +// CHECK:STDERR: fail_no_semi.carbon:[[@LINE+3]]:21: `package` declarations must end with a `;`. +// CHECK:STDERR: package Geometry api +// CHECK:STDERR: ^ package Geometry api diff --git a/toolchain/parser/testdata/package/fail_no_type.carbon b/toolchain/parser/testdata/package/fail_no_type.carbon index e141bb78b3e8..cd8a710f43cb 100644 --- a/toolchain/parser/testdata/package/fail_no_type.carbon +++ b/toolchain/parser/testdata/package/fail_no_type.carbon @@ -10,5 +10,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_no_type.carbon:[[@LINE+1]]:17: Expected a `api` or `impl`. +// CHECK:STDERR: fail_no_type.carbon:[[@LINE+3]]:17: Expected a `api` or `impl`. +// CHECK:STDERR: package Geometry; +// CHECK:STDERR: ^ package Geometry; diff --git a/toolchain/parser/testdata/package/fail_omit_library_keyword.carbon b/toolchain/parser/testdata/package/fail_omit_library_keyword.carbon index a55e7c4febbc..92f26fd94d44 100644 --- a/toolchain/parser/testdata/package/fail_omit_library_keyword.carbon +++ b/toolchain/parser/testdata/package/fail_omit_library_keyword.carbon @@ -10,5 +10,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_omit_library_keyword.carbon:[[@LINE+1]]:18: Missing `library` keyword. +// CHECK:STDERR: fail_omit_library_keyword.carbon:[[@LINE+3]]:18: Missing `library` keyword. +// CHECK:STDERR: package Geometry "Shapes" api; +// CHECK:STDERR: ^ package Geometry "Shapes" api; diff --git a/toolchain/parser/testdata/return/fail_expr_no_semi.carbon b/toolchain/parser/testdata/return/fail_expr_no_semi.carbon index 50f4de959723..64ac3458ac5d 100644 --- a/toolchain/parser/testdata/return/fail_expr_no_semi.carbon +++ b/toolchain/parser/testdata/return/fail_expr_no_semi.carbon @@ -18,5 +18,7 @@ fn F() { return x -// CHECK:STDERR: fail_expr_no_semi.carbon:[[@LINE+1]]:1: `return` statements must end with a `;`. +// CHECK:STDERR: fail_expr_no_semi.carbon:[[@LINE+3]]:1: `return` statements must end with a `;`. +// CHECK:STDERR: } +// CHECK:STDERR: ^ } diff --git a/toolchain/parser/testdata/return/fail_no_semi.carbon b/toolchain/parser/testdata/return/fail_no_semi.carbon index 9376ddd33b9b..014111d12e92 100644 --- a/toolchain/parser/testdata/return/fail_no_semi.carbon +++ b/toolchain/parser/testdata/return/fail_no_semi.carbon @@ -18,6 +18,10 @@ fn F() { return -// CHECK:STDERR: fail_no_semi.carbon:[[@LINE+2]]:1: Expected expression. -// CHECK:STDERR: fail_no_semi.carbon:[[@LINE+1]]:1: `return` statements must end with a `;`. +// CHECK:STDERR: fail_no_semi.carbon:[[@LINE+6]]:1: Expected expression. +// CHECK:STDERR: } +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_no_semi.carbon:[[@LINE+3]]:1: `return` statements must end with a `;`. +// CHECK:STDERR: } +// CHECK:STDERR: ^ } diff --git a/toolchain/parser/testdata/struct/fail_comma_only.carbon b/toolchain/parser/testdata/struct/fail_comma_only.carbon index 8e1c722810b8..e3d10da072e3 100644 --- a/toolchain/parser/testdata/struct/fail_comma_only.carbon +++ b/toolchain/parser/testdata/struct/fail_comma_only.carbon @@ -18,5 +18,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_comma_only.carbon:[[@LINE+1]]:9: Expected `.field: field_type` or `.field = value`. +// CHECK:STDERR: fail_comma_only.carbon:[[@LINE+3]]:9: Expected `.field: field_type` or `.field = value`. +// CHECK:STDERR: var x: {,} = {}; +// CHECK:STDERR: ^ var x: {,} = {}; diff --git a/toolchain/parser/testdata/struct/fail_comma_repeat_in_type.carbon b/toolchain/parser/testdata/struct/fail_comma_repeat_in_type.carbon index 0419d972d410..a1bbab61cd11 100644 --- a/toolchain/parser/testdata/struct/fail_comma_repeat_in_type.carbon +++ b/toolchain/parser/testdata/struct/fail_comma_repeat_in_type.carbon @@ -23,5 +23,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_comma_repeat_in_type.carbon:[[@LINE+1]]:17: Expected `.field: field_type`. +// CHECK:STDERR: fail_comma_repeat_in_type.carbon:[[@LINE+3]]:17: Expected `.field: field_type`. +// CHECK:STDERR: var x: {.a: i32,,} = {}; +// CHECK:STDERR: ^ var x: {.a: i32,,} = {}; diff --git a/toolchain/parser/testdata/struct/fail_comma_repeat_in_value.carbon b/toolchain/parser/testdata/struct/fail_comma_repeat_in_value.carbon index d6d821688230..20c48a74f155 100644 --- a/toolchain/parser/testdata/struct/fail_comma_repeat_in_value.carbon +++ b/toolchain/parser/testdata/struct/fail_comma_repeat_in_value.carbon @@ -23,5 +23,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_comma_repeat_in_value.carbon:[[@LINE+1]]:16: Expected `.field = value`. +// CHECK:STDERR: fail_comma_repeat_in_value.carbon:[[@LINE+3]]:16: Expected `.field = value`. +// CHECK:STDERR: var x: {.a = 0,,} = {}; +// CHECK:STDERR: ^ var x: {.a = 0,,} = {}; diff --git a/toolchain/parser/testdata/struct/fail_dot_only.carbon b/toolchain/parser/testdata/struct/fail_dot_only.carbon index d45b68be649f..a42901dd029e 100644 --- a/toolchain/parser/testdata/struct/fail_dot_only.carbon +++ b/toolchain/parser/testdata/struct/fail_dot_only.carbon @@ -19,5 +19,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_dot_only.carbon:[[@LINE+1]]:10: Expected identifier after `.`. +// CHECK:STDERR: fail_dot_only.carbon:[[@LINE+3]]:10: Expected identifier after `.`. +// CHECK:STDERR: var x: {.} = {}; +// CHECK:STDERR: ^ var x: {.} = {}; diff --git a/toolchain/parser/testdata/struct/fail_dot_string_colon.carbon b/toolchain/parser/testdata/struct/fail_dot_string_colon.carbon index d388e66cb0e1..f28f39b87977 100644 --- a/toolchain/parser/testdata/struct/fail_dot_string_colon.carbon +++ b/toolchain/parser/testdata/struct/fail_dot_string_colon.carbon @@ -25,5 +25,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_dot_string_colon.carbon:[[@LINE+1]]:10: Expected identifier after `.`. +// CHECK:STDERR: fail_dot_string_colon.carbon:[[@LINE+3]]:10: Expected identifier after `.`. +// CHECK:STDERR: var x: {."hello": i32, .y: i32} = {}; +// CHECK:STDERR: ^ var x: {."hello": i32, .y: i32} = {}; diff --git a/toolchain/parser/testdata/struct/fail_dot_string_equals.carbon b/toolchain/parser/testdata/struct/fail_dot_string_equals.carbon index 98cbe58520b5..91b372d5d258 100644 --- a/toolchain/parser/testdata/struct/fail_dot_string_equals.carbon +++ b/toolchain/parser/testdata/struct/fail_dot_string_equals.carbon @@ -25,5 +25,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_dot_string_equals.carbon:[[@LINE+1]]:10: Expected identifier after `.`. +// CHECK:STDERR: fail_dot_string_equals.carbon:[[@LINE+3]]:10: Expected identifier after `.`. +// CHECK:STDERR: var x: {."hello" = 0, .y = 4} = {}; +// CHECK:STDERR: ^ var x: {."hello" = 0, .y = 4} = {}; diff --git a/toolchain/parser/testdata/struct/fail_extra_token_in_type.carbon b/toolchain/parser/testdata/struct/fail_extra_token_in_type.carbon index 19d17befbab8..bd45d859395b 100644 --- a/toolchain/parser/testdata/struct/fail_extra_token_in_type.carbon +++ b/toolchain/parser/testdata/struct/fail_extra_token_in_type.carbon @@ -24,5 +24,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_extra_token_in_type.carbon:[[@LINE+1]]:17: Expected `,` or `}`. +// CHECK:STDERR: fail_extra_token_in_type.carbon:[[@LINE+3]]:17: Expected `,` or `}`. +// CHECK:STDERR: var x: {.a: i32 banana} = {.a = 0}; +// CHECK:STDERR: ^ var x: {.a: i32 banana} = {.a = 0}; diff --git a/toolchain/parser/testdata/struct/fail_extra_token_in_value.carbon b/toolchain/parser/testdata/struct/fail_extra_token_in_value.carbon index c49a4c163473..bd85d0007fd5 100644 --- a/toolchain/parser/testdata/struct/fail_extra_token_in_value.carbon +++ b/toolchain/parser/testdata/struct/fail_extra_token_in_value.carbon @@ -24,5 +24,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_extra_token_in_value.carbon:[[@LINE+1]]:28: Expected `,` or `}`. +// CHECK:STDERR: fail_extra_token_in_value.carbon:[[@LINE+3]]:28: Expected `,` or `}`. +// CHECK:STDERR: var x: {.a: i32} = {.a = 0 banana}; +// CHECK:STDERR: ^ var x: {.a: i32} = {.a = 0 banana}; diff --git a/toolchain/parser/testdata/struct/fail_identifier_colon.carbon b/toolchain/parser/testdata/struct/fail_identifier_colon.carbon index 185e03584b70..b2030bb2db55 100644 --- a/toolchain/parser/testdata/struct/fail_identifier_colon.carbon +++ b/toolchain/parser/testdata/struct/fail_identifier_colon.carbon @@ -17,5 +17,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_identifier_colon.carbon:[[@LINE+1]]:9: Expected `.field: field_type` or `.field = value`. +// CHECK:STDERR: fail_identifier_colon.carbon:[[@LINE+3]]:9: Expected `.field: field_type` or `.field = value`. +// CHECK:STDERR: var x: {a:} = {}; +// CHECK:STDERR: ^ var x: {a:} = {}; diff --git a/toolchain/parser/testdata/struct/fail_identifier_equals.carbon b/toolchain/parser/testdata/struct/fail_identifier_equals.carbon index b82a4b0090dd..a9176b6610e0 100644 --- a/toolchain/parser/testdata/struct/fail_identifier_equals.carbon +++ b/toolchain/parser/testdata/struct/fail_identifier_equals.carbon @@ -17,5 +17,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_identifier_equals.carbon:[[@LINE+1]]:9: Expected `.field: field_type` or `.field = value`. +// CHECK:STDERR: fail_identifier_equals.carbon:[[@LINE+3]]:9: Expected `.field: field_type` or `.field = value`. +// CHECK:STDERR: var x: {a=} = {}; +// CHECK:STDERR: ^ var x: {a=} = {}; diff --git a/toolchain/parser/testdata/struct/fail_identifier_only.carbon b/toolchain/parser/testdata/struct/fail_identifier_only.carbon index 4363e5140bee..a8565c2268b4 100644 --- a/toolchain/parser/testdata/struct/fail_identifier_only.carbon +++ b/toolchain/parser/testdata/struct/fail_identifier_only.carbon @@ -17,5 +17,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_identifier_only.carbon:[[@LINE+1]]:9: Expected `.field: field_type` or `.field = value`. +// CHECK:STDERR: fail_identifier_only.carbon:[[@LINE+3]]:9: Expected `.field: field_type` or `.field = value`. +// CHECK:STDERR: var x: {a} = {}; +// CHECK:STDERR: ^ var x: {a} = {}; diff --git a/toolchain/parser/testdata/struct/fail_missing_type.carbon b/toolchain/parser/testdata/struct/fail_missing_type.carbon index deb22320e8cf..1affff661fb5 100644 --- a/toolchain/parser/testdata/struct/fail_missing_type.carbon +++ b/toolchain/parser/testdata/struct/fail_missing_type.carbon @@ -20,5 +20,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_missing_type.carbon:[[@LINE+1]]:12: Expected expression. +// CHECK:STDERR: fail_missing_type.carbon:[[@LINE+3]]:12: Expected expression. +// CHECK:STDERR: var x: {.a:} = {}; +// CHECK:STDERR: ^ var x: {.a:} = {}; diff --git a/toolchain/parser/testdata/struct/fail_missing_value.carbon b/toolchain/parser/testdata/struct/fail_missing_value.carbon index ab7436194356..ca645759bc02 100644 --- a/toolchain/parser/testdata/struct/fail_missing_value.carbon +++ b/toolchain/parser/testdata/struct/fail_missing_value.carbon @@ -20,5 +20,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_missing_value.carbon:[[@LINE+1]]:12: Expected expression. +// CHECK:STDERR: fail_missing_value.carbon:[[@LINE+3]]:12: Expected expression. +// CHECK:STDERR: var x: {.a=} = {}; +// CHECK:STDERR: ^ var x: {.a=} = {}; diff --git a/toolchain/parser/testdata/struct/fail_mix_type_and_value.carbon b/toolchain/parser/testdata/struct/fail_mix_type_and_value.carbon index ebd1372aae30..c164ac2c4a5c 100644 --- a/toolchain/parser/testdata/struct/fail_mix_type_and_value.carbon +++ b/toolchain/parser/testdata/struct/fail_mix_type_and_value.carbon @@ -24,5 +24,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_mix_type_and_value.carbon:[[@LINE+1]]:21: Expected `.field: field_type`. +// CHECK:STDERR: fail_mix_type_and_value.carbon:[[@LINE+3]]:21: Expected `.field: field_type`. +// CHECK:STDERR: var x: {.a: i32, .b = 0} = {}; +// CHECK:STDERR: ^ var x: {.a: i32, .b = 0} = {}; diff --git a/toolchain/parser/testdata/struct/fail_mix_value_and_type.carbon b/toolchain/parser/testdata/struct/fail_mix_value_and_type.carbon index 09e0f69525da..84d5f62ef8e8 100644 --- a/toolchain/parser/testdata/struct/fail_mix_value_and_type.carbon +++ b/toolchain/parser/testdata/struct/fail_mix_value_and_type.carbon @@ -22,5 +22,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_mix_value_and_type.carbon:[[@LINE+1]]:17: Expected `.field = value`. +// CHECK:STDERR: fail_mix_value_and_type.carbon:[[@LINE+3]]:17: Expected `.field = value`. +// CHECK:STDERR: var x: {.a = 0, b: i32} = {}; +// CHECK:STDERR: ^ var x: {.a = 0, b: i32} = {}; diff --git a/toolchain/parser/testdata/struct/fail_mix_with_unknown.carbon b/toolchain/parser/testdata/struct/fail_mix_with_unknown.carbon index 210dad8eca04..e0acb8c622d4 100644 --- a/toolchain/parser/testdata/struct/fail_mix_with_unknown.carbon +++ b/toolchain/parser/testdata/struct/fail_mix_with_unknown.carbon @@ -47,10 +47,18 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_mix_with_unknown.carbon:[[@LINE+2]]:25: Expected `.field = value`. -// CHECK:STDERR: fail_mix_with_unknown.carbon:[[@LINE+1]]:29: Expected `.field = value`. +// CHECK:STDERR: fail_mix_with_unknown.carbon:[[@LINE+6]]:25: Expected `.field = value`. +// CHECK:STDERR: var x: i32 = {.a = 1, .b, .c: i32}; +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_mix_with_unknown.carbon:[[@LINE+3]]:29: Expected `.field = value`. +// CHECK:STDERR: var x: i32 = {.a = 1, .b, .c: i32}; +// CHECK:STDERR: ^ var x: i32 = {.a = 1, .b, .c: i32}; -// CHECK:STDERR: fail_mix_with_unknown.carbon:[[@LINE+2]]:26: Expected `.field: field_type`. -// CHECK:STDERR: fail_mix_with_unknown.carbon:[[@LINE+1]]:31: Expected `.field: field_type`. +// CHECK:STDERR: fail_mix_with_unknown.carbon:[[@LINE+6]]:26: Expected `.field: field_type`. +// CHECK:STDERR: var x: i32 = {.a: i32, .b, .c = 1}; +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_mix_with_unknown.carbon:[[@LINE+3]]:31: Expected `.field: field_type`. +// CHECK:STDERR: var x: i32 = {.a: i32, .b, .c = 1}; +// CHECK:STDERR: ^ var x: i32 = {.a: i32, .b, .c = 1}; diff --git a/toolchain/parser/testdata/struct/fail_no_colon_or_equals.carbon b/toolchain/parser/testdata/struct/fail_no_colon_or_equals.carbon index 2e8e6734e1e6..7715a5738ffc 100644 --- a/toolchain/parser/testdata/struct/fail_no_colon_or_equals.carbon +++ b/toolchain/parser/testdata/struct/fail_no_colon_or_equals.carbon @@ -19,5 +19,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_no_colon_or_equals.carbon:[[@LINE+1]]:11: Expected `.field: field_type` or `.field = value`. +// CHECK:STDERR: fail_no_colon_or_equals.carbon:[[@LINE+3]]:11: Expected `.field: field_type` or `.field = value`. +// CHECK:STDERR: var x: {.a} = {}; +// CHECK:STDERR: ^ var x: {.a} = {}; diff --git a/toolchain/parser/testdata/struct/fail_type_no_designator.carbon b/toolchain/parser/testdata/struct/fail_type_no_designator.carbon index 0e613e78fcf6..d8edfaedd52c 100644 --- a/toolchain/parser/testdata/struct/fail_type_no_designator.carbon +++ b/toolchain/parser/testdata/struct/fail_type_no_designator.carbon @@ -17,5 +17,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_type_no_designator.carbon:[[@LINE+1]]:9: Expected `.field: field_type` or `.field = value`. +// CHECK:STDERR: fail_type_no_designator.carbon:[[@LINE+3]]:9: Expected `.field: field_type` or `.field = value`. +// CHECK:STDERR: var x: {i32} = {}; +// CHECK:STDERR: ^ var x: {i32} = {}; diff --git a/toolchain/parser/testdata/var/fail_bad_name.carbon b/toolchain/parser/testdata/var/fail_bad_name.carbon index 59cba0514408..3d67a24a0631 100644 --- a/toolchain/parser/testdata/var/fail_bad_name.carbon +++ b/toolchain/parser/testdata/var/fail_bad_name.carbon @@ -12,5 +12,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_bad_name.carbon:[[@LINE+1]]:5: Expected pattern in `var` declaration. +// CHECK:STDERR: fail_bad_name.carbon:[[@LINE+3]]:5: Expected pattern in `var` declaration. +// CHECK:STDERR: var *; +// CHECK:STDERR: ^ var *; diff --git a/toolchain/parser/testdata/var/fail_empty.carbon b/toolchain/parser/testdata/var/fail_empty.carbon index 76327b8a7171..8afb19061e17 100644 --- a/toolchain/parser/testdata/var/fail_empty.carbon +++ b/toolchain/parser/testdata/var/fail_empty.carbon @@ -12,5 +12,7 @@ // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] -// CHECK:STDERR: fail_empty.carbon:[[@LINE+1]]:4: Expected pattern in `var` declaration. +// CHECK:STDERR: fail_empty.carbon:[[@LINE+3]]:4: Expected pattern in `var` declaration. +// CHECK:STDERR: var; +// CHECK:STDERR: ^ var; diff --git a/toolchain/parser/testdata/while/fail_no_semi.carbon b/toolchain/parser/testdata/while/fail_no_semi.carbon index 3d2090ce2af3..044de06d35ea 100644 --- a/toolchain/parser/testdata/while/fail_no_semi.carbon +++ b/toolchain/parser/testdata/while/fail_no_semi.carbon @@ -39,11 +39,15 @@ fn F() { while (a) { if (b) { break - // CHECK:STDERR: fail_no_semi.carbon:[[@LINE+1]]:5: `break` statements must end with a `;`. + // CHECK:STDERR: fail_no_semi.carbon:[[@LINE+3]]:5: `break` statements must end with a `;`. + // CHECK:STDERR: } + // CHECK:STDERR: ^ } if (c) { continue - // CHECK:STDERR: fail_no_semi.carbon:[[@LINE+1]]:5: `continue` statements must end with a `;`. + // CHECK:STDERR: fail_no_semi.carbon:[[@LINE+3]]:5: `continue` statements must end with a `;`. + // CHECK:STDERR: } + // CHECK:STDERR: ^ } } } diff --git a/toolchain/parser/testdata/while/fail_unbraced.carbon b/toolchain/parser/testdata/while/fail_unbraced.carbon index c5cc75d8c442..1c97a2b65d42 100644 --- a/toolchain/parser/testdata/while/fail_unbraced.carbon +++ b/toolchain/parser/testdata/while/fail_unbraced.carbon @@ -24,6 +24,8 @@ fn F() { while (a) - // CHECK:STDERR: fail_unbraced.carbon:[[@LINE+1]]:5: Expected braced code block. + // CHECK:STDERR: fail_unbraced.carbon:[[@LINE+3]]:5: Expected braced code block. + // CHECK:STDERR: break; + // CHECK:STDERR: ^ break; } diff --git a/toolchain/semantics/testdata/basics/fail_name_lookup.carbon b/toolchain/semantics/testdata/basics/fail_name_lookup.carbon index c467714abd1e..a88b441c32e8 100644 --- a/toolchain/semantics/testdata/basics/fail_name_lookup.carbon +++ b/toolchain/semantics/testdata/basics/fail_name_lookup.carbon @@ -36,6 +36,8 @@ // CHECK:STDOUT: ] fn Main() { - // CHECK:STDERR: fail_name_lookup.carbon:[[@LINE+1]]:3: Name x not found + // CHECK:STDERR: fail_name_lookup.carbon:[[@LINE+3]]:3: Name x not found + // CHECK:STDERR: x; + // CHECK:STDERR: ^ x; } diff --git a/toolchain/semantics/testdata/basics/fail_qualifier_unsupported.carbon b/toolchain/semantics/testdata/basics/fail_qualifier_unsupported.carbon index 02e01c1d04c6..323aa32515ce 100644 --- a/toolchain/semantics/testdata/basics/fail_qualifier_unsupported.carbon +++ b/toolchain/semantics/testdata/basics/fail_qualifier_unsupported.carbon @@ -40,5 +40,7 @@ // CHECK:STDOUT: ] var x: i32; -// CHECK:STDERR: fail_qualifier_unsupported.carbon:[[@LINE+1]]:15: Type `i32` does not support qualified expressions. +// CHECK:STDERR: fail_qualifier_unsupported.carbon:[[@LINE+3]]:15: Type `i32` does not support qualified expressions. +// CHECK:STDERR: var y: i32 = x.b; +// CHECK:STDERR: ^ var y: i32 = x.b; diff --git a/toolchain/semantics/testdata/function/call/fail_param_count.carbon b/toolchain/semantics/testdata/function/call/fail_param_count.carbon index 5365ddeb035b..0e88f3dba52d 100644 --- a/toolchain/semantics/testdata/function/call/fail_param_count.carbon +++ b/toolchain/semantics/testdata/function/call/fail_param_count.carbon @@ -133,24 +133,48 @@ fn Run1(a: i32) {} fn Run2(a: i32, b: i32) {} fn Main() { - // CHECK:STDERR: fail_param_count.carbon:[[@LINE+2]]:7: No matching callable was found. - // CHECK:STDERR: fail_param_count.carbon:[[@LINE-6]]:1: Function cannot be used: Received 1 argument(s), but require 0 argument(s). + // CHECK:STDERR: fail_param_count.carbon:[[@LINE+6]]:7: No matching callable was found. + // CHECK:STDERR: Run0(1); + // CHECK:STDERR: ^ + // CHECK:STDERR: fail_param_count.carbon:[[@LINE-8]]:1: Function cannot be used: Received 1 argument(s), but require 0 argument(s). + // CHECK:STDERR: fn Run0() {} + // CHECK:STDERR: ^ Run0(1); - // CHECK:STDERR: fail_param_count.carbon:[[@LINE+2]]:7: No matching callable was found. - // CHECK:STDERR: fail_param_count.carbon:[[@LINE-9]]:1: Function cannot be used: Received 2 argument(s), but require 0 argument(s). + // CHECK:STDERR: fail_param_count.carbon:[[@LINE+6]]:7: No matching callable was found. + // CHECK:STDERR: Run0(0, 1); + // CHECK:STDERR: ^ + // CHECK:STDERR: fail_param_count.carbon:[[@LINE-15]]:1: Function cannot be used: Received 2 argument(s), but require 0 argument(s). + // CHECK:STDERR: fn Run0() {} + // CHECK:STDERR: ^ Run0(0, 1); - // CHECK:STDERR: fail_param_count.carbon:[[@LINE+2]]:7: No matching callable was found. - // CHECK:STDERR: fail_param_count.carbon:[[@LINE-12]]:1: Function cannot be used: Received 0 argument(s), but require 1 argument(s). + // CHECK:STDERR: fail_param_count.carbon:[[@LINE+6]]:7: No matching callable was found. + // CHECK:STDERR: Run1(); + // CHECK:STDERR: ^ + // CHECK:STDERR: fail_param_count.carbon:[[@LINE-22]]:1: Function cannot be used: Received 0 argument(s), but require 1 argument(s). + // CHECK:STDERR: fn Run1(a: i32) {} + // CHECK:STDERR: ^ Run1(); - // CHECK:STDERR: fail_param_count.carbon:[[@LINE+2]]:7: No matching callable was found. - // CHECK:STDERR: fail_param_count.carbon:[[@LINE-15]]:1: Function cannot be used: Received 2 argument(s), but require 1 argument(s). + // CHECK:STDERR: fail_param_count.carbon:[[@LINE+6]]:7: No matching callable was found. + // CHECK:STDERR: Run1(0, 1); + // CHECK:STDERR: ^ + // CHECK:STDERR: fail_param_count.carbon:[[@LINE-29]]:1: Function cannot be used: Received 2 argument(s), but require 1 argument(s). + // CHECK:STDERR: fn Run1(a: i32) {} + // CHECK:STDERR: ^ Run1(0, 1); - // CHECK:STDERR: fail_param_count.carbon:[[@LINE+2]]:7: No matching callable was found. - // CHECK:STDERR: fail_param_count.carbon:[[@LINE-18]]:1: Function cannot be used: Received 0 argument(s), but require 2 argument(s). + // CHECK:STDERR: fail_param_count.carbon:[[@LINE+6]]:7: No matching callable was found. + // CHECK:STDERR: Run2(); + // CHECK:STDERR: ^ + // CHECK:STDERR: fail_param_count.carbon:[[@LINE-36]]:1: Function cannot be used: Received 0 argument(s), but require 2 argument(s). + // CHECK:STDERR: fn Run2(a: i32, b: i32) {} + // CHECK:STDERR: ^ Run2(); - // CHECK:STDERR: fail_param_count.carbon:[[@LINE+2]]:7: No matching callable was found. - // CHECK:STDERR: fail_param_count.carbon:[[@LINE-21]]:1: Function cannot be used: Received 1 argument(s), but require 2 argument(s). + // CHECK:STDERR: fail_param_count.carbon:[[@LINE+6]]:7: No matching callable was found. + // CHECK:STDERR: Run2(0); + // CHECK:STDERR: ^ + // CHECK:STDERR: fail_param_count.carbon:[[@LINE-43]]:1: Function cannot be used: Received 1 argument(s), but require 2 argument(s). + // CHECK:STDERR: fn Run2(a: i32, b: i32) {} + // CHECK:STDERR: ^ Run2(0); } diff --git a/toolchain/semantics/testdata/function/call/fail_param_type.carbon b/toolchain/semantics/testdata/function/call/fail_param_type.carbon index 9559e76b2997..3ab17f9b1d06 100644 --- a/toolchain/semantics/testdata/function/call/fail_param_type.carbon +++ b/toolchain/semantics/testdata/function/call/fail_param_type.carbon @@ -65,7 +65,11 @@ fn Run(a: i32) {} fn Main() { - // CHECK:STDERR: fail_param_type.carbon:[[@LINE+2]]:6: No matching callable was found. - // CHECK:STDERR: fail_param_type.carbon:[[@LINE-4]]:1: Function cannot be used: Cannot implicityly convert argument 0 from `f64` to `i32`. + // CHECK:STDERR: fail_param_type.carbon:[[@LINE+6]]:6: No matching callable was found. + // CHECK:STDERR: Run(1.0); + // CHECK:STDERR: ^ + // CHECK:STDERR: fail_param_type.carbon:[[@LINE-6]]:1: Function cannot be used: Cannot implicityly convert argument 0 from `f64` to `i32`. + // CHECK:STDERR: fn Run(a: i32) {} + // CHECK:STDERR: ^ Run(1.0); } diff --git a/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon b/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon index e7c2dbe62d53..7c09db930993 100644 --- a/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon +++ b/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon @@ -59,6 +59,8 @@ fn Foo() -> f64 { return 1.0; } fn Run() { - // CHECK:STDERR: fail_return_type_mismatch.carbon:[[@LINE+1]]:21: Cannot implicitly convert from `f64` to `i32`. + // CHECK:STDERR: fail_return_type_mismatch.carbon:[[@LINE+3]]:21: Cannot implicitly convert from `f64` to `i32`. + // CHECK:STDERR: var x: i32 = Foo(); + // CHECK:STDERR: ^ var x: i32 = Foo(); } diff --git a/toolchain/semantics/testdata/function/definition/fail_param_name_conflict.carbon b/toolchain/semantics/testdata/function/definition/fail_param_name_conflict.carbon index d654a8debb45..24fd7eff36bb 100644 --- a/toolchain/semantics/testdata/function/definition/fail_param_name_conflict.carbon +++ b/toolchain/semantics/testdata/function/definition/fail_param_name_conflict.carbon @@ -50,6 +50,10 @@ // CHECK:STDOUT: ], // CHECK:STDOUT: ] -// CHECK:STDERR: fail_param_name_conflict.carbon:[[@LINE+2]]:16: Duplicate name being declared in the same scope. -// CHECK:STDERR: fail_param_name_conflict.carbon:[[@LINE+1]]:8: Name is previously declared here. +// CHECK:STDERR: fail_param_name_conflict.carbon:[[@LINE+6]]:16: Duplicate name being declared in the same scope. +// CHECK:STDERR: fn Bar(a: i32, a: i32) {} +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_param_name_conflict.carbon:[[@LINE+3]]:8: Name is previously declared here. +// CHECK:STDERR: fn Bar(a: i32, a: i32) {} +// CHECK:STDERR: ^ fn Bar(a: i32, a: i32) {} diff --git a/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon b/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon index 18318512b519..81322c4da9dc 100644 --- a/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon +++ b/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon @@ -126,7 +126,9 @@ fn If1(b: bool) -> i32 { return 1; } else { } -// CHECK:STDERR: fail_reachable_fallthrough.carbon:[[@LINE+1]]:1: Missing `return` at end of function with declared return type. +// CHECK:STDERR: fail_reachable_fallthrough.carbon:[[@LINE+3]]:1: Missing `return` at end of function with declared return type. +// CHECK:STDERR: } +// CHECK:STDERR: ^ } fn If2(b: bool) -> i32 { @@ -134,12 +136,16 @@ fn If2(b: bool) -> i32 { } else { return 2; } -// CHECK:STDERR: fail_reachable_fallthrough.carbon:[[@LINE+1]]:1: Missing `return` at end of function with declared return type. +// CHECK:STDERR: fail_reachable_fallthrough.carbon:[[@LINE+3]]:1: Missing `return` at end of function with declared return type. +// CHECK:STDERR: } +// CHECK:STDERR: ^ } fn If3(b: bool) -> i32 { if (b) { return 1; } -// CHECK:STDERR: fail_reachable_fallthrough.carbon:[[@LINE+1]]:1: Missing `return` at end of function with declared return type. +// CHECK:STDERR: fail_reachable_fallthrough.carbon:[[@LINE+3]]:1: Missing `return` at end of function with declared return type. +// CHECK:STDERR: } +// CHECK:STDERR: ^ } diff --git a/toolchain/semantics/testdata/if/fail_scope.carbon b/toolchain/semantics/testdata/if/fail_scope.carbon index 96c8eaa59435..5d94e3c8df37 100644 --- a/toolchain/semantics/testdata/if/fail_scope.carbon +++ b/toolchain/semantics/testdata/if/fail_scope.carbon @@ -71,6 +71,8 @@ fn VarScope(b: bool) -> i32 { var n: i32 = 2; return n; } - // CHECK:STDERR: fail_scope.carbon:[[@LINE+1]]:10: Name n not found + // CHECK:STDERR: fail_scope.carbon:[[@LINE+3]]:10: Name n not found + // CHECK:STDERR: return n; + // CHECK:STDERR: ^ return n; } diff --git a/toolchain/semantics/testdata/namespace/fail_duplicate.carbon b/toolchain/semantics/testdata/namespace/fail_duplicate.carbon index 204793dae277..80dbc508a8cc 100644 --- a/toolchain/semantics/testdata/namespace/fail_duplicate.carbon +++ b/toolchain/semantics/testdata/namespace/fail_duplicate.carbon @@ -49,7 +49,11 @@ namespace Foo; fn Foo.Baz() { } -// CHECK:STDERR: fail_duplicate.carbon:[[@LINE+2]]:8: Duplicate name being declared in the same scope. -// CHECK:STDERR: fail_duplicate.carbon:[[@LINE-4]]:1: Name is previously declared here. +// CHECK:STDERR: fail_duplicate.carbon:[[@LINE+6]]:8: Duplicate name being declared in the same scope. +// CHECK:STDERR: fn Foo.Baz() { +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_duplicate.carbon:[[@LINE-6]]:1: Name is previously declared here. +// CHECK:STDERR: fn Foo.Baz() { +// CHECK:STDERR: ^ fn Foo.Baz() { } diff --git a/toolchain/semantics/testdata/namespace/fail_unresolved_scope.carbon b/toolchain/semantics/testdata/namespace/fail_unresolved_scope.carbon index 1adc10bc4730..ba7776663f11 100644 --- a/toolchain/semantics/testdata/namespace/fail_unresolved_scope.carbon +++ b/toolchain/semantics/testdata/namespace/fail_unresolved_scope.carbon @@ -35,6 +35,8 @@ // CHECK:STDOUT: ], // CHECK:STDOUT: ] -// CHECK:STDERR: fail_unresolved_scope.carbon:[[@LINE+1]]:4: Name Foo not found +// CHECK:STDERR: fail_unresolved_scope.carbon:[[@LINE+3]]:4: Name Foo not found +// CHECK:STDERR: fn Foo.Baz() { +// CHECK:STDERR: ^ fn Foo.Baz() { } diff --git a/toolchain/semantics/testdata/operators/fail_type_mismatch.carbon b/toolchain/semantics/testdata/operators/fail_type_mismatch.carbon index ac11ad151590..dcdb72b92a58 100644 --- a/toolchain/semantics/testdata/operators/fail_type_mismatch.carbon +++ b/toolchain/semantics/testdata/operators/fail_type_mismatch.carbon @@ -44,6 +44,8 @@ // CHECK:STDOUT: ] fn Main() -> i32 { - // CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+1]]:13: Cannot implicitly convert from `i32` to `f64`. + // CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+3]]:13: Cannot implicitly convert from `i32` to `f64`. + // CHECK:STDERR: return 12 + 3.4; + // CHECK:STDERR: ^ return 12 + 3.4; } diff --git a/toolchain/semantics/testdata/operators/fail_type_mismatch_once.carbon b/toolchain/semantics/testdata/operators/fail_type_mismatch_once.carbon index 9347ccb1ecfa..2dbb942dc090 100644 --- a/toolchain/semantics/testdata/operators/fail_type_mismatch_once.carbon +++ b/toolchain/semantics/testdata/operators/fail_type_mismatch_once.carbon @@ -51,6 +51,8 @@ fn Main() -> i32 { // The following line has two mismatches, but after the first, it shouldn't // keep erroring. - // CHECK:STDERR: fail_type_mismatch_once.carbon:[[@LINE+1]]:13: Cannot implicitly convert from `i32` to `f64`. + // CHECK:STDERR: fail_type_mismatch_once.carbon:[[@LINE+3]]:13: Cannot implicitly convert from `i32` to `f64`. + // CHECK:STDERR: return 12 + 3.4 + 12; + // CHECK:STDERR: ^ return 12 + 3.4 + 12; } diff --git a/toolchain/semantics/testdata/return/fail_missing_return.carbon b/toolchain/semantics/testdata/return/fail_missing_return.carbon index 235fdfbe6d06..7589d0a2373a 100644 --- a/toolchain/semantics/testdata/return/fail_missing_return.carbon +++ b/toolchain/semantics/testdata/return/fail_missing_return.carbon @@ -33,5 +33,7 @@ // CHECK:STDOUT: ] fn Main() -> i32 { -// CHECK:STDERR: fail_missing_return.carbon:[[@LINE+1]]:1: Missing `return` at end of function with declared return type. +// CHECK:STDERR: fail_missing_return.carbon:[[@LINE+3]]:1: Missing `return` at end of function with declared return type. +// CHECK:STDERR: } +// CHECK:STDERR: ^ } diff --git a/toolchain/semantics/testdata/return/fail_missing_return_empty_tuple.carbon b/toolchain/semantics/testdata/return/fail_missing_return_empty_tuple.carbon index 905458e9070c..d81808b551d1 100644 --- a/toolchain/semantics/testdata/return/fail_missing_return_empty_tuple.carbon +++ b/toolchain/semantics/testdata/return/fail_missing_return_empty_tuple.carbon @@ -39,5 +39,7 @@ // CHECK:STDOUT: ] fn F() -> () { -// CHECK:STDERR: fail_missing_return_empty_tuple.carbon:[[@LINE+1]]:1: Missing `return` at end of function with declared return type. +// CHECK:STDERR: fail_missing_return_empty_tuple.carbon:[[@LINE+3]]:1: Missing `return` at end of function with declared return type. +// CHECK:STDERR: } +// CHECK:STDERR: ^ } diff --git a/toolchain/semantics/testdata/return/fail_type_mismatch.carbon b/toolchain/semantics/testdata/return/fail_type_mismatch.carbon index 7865f32b09ae..96ac9af144aa 100644 --- a/toolchain/semantics/testdata/return/fail_type_mismatch.carbon +++ b/toolchain/semantics/testdata/return/fail_type_mismatch.carbon @@ -39,6 +39,8 @@ // CHECK:STDOUT: ] fn Main() -> i32 { - // CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+1]]:13: Cannot implicitly convert from `f64` to `i32`. + // CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+3]]:13: Cannot implicitly convert from `f64` to `i32`. + // CHECK:STDERR: return 1.0; + // CHECK:STDERR: ^ return 1.0; } diff --git a/toolchain/semantics/testdata/return/fail_value_disallowed.carbon b/toolchain/semantics/testdata/return/fail_value_disallowed.carbon index acf71cbffb3c..40eab2138414 100644 --- a/toolchain/semantics/testdata/return/fail_value_disallowed.carbon +++ b/toolchain/semantics/testdata/return/fail_value_disallowed.carbon @@ -39,7 +39,11 @@ // CHECK:STDOUT: ] fn Main() { - // CHECK:STDERR: fail_value_disallowed.carbon:[[@LINE+2]]:11: No return expression should be provided in this context. - // CHECK:STDERR: fail_value_disallowed.carbon:[[@LINE-2]]:1: There was no return type provided. + // CHECK:STDERR: fail_value_disallowed.carbon:[[@LINE+6]]:11: No return expression should be provided in this context. + // CHECK:STDERR: return 0; + // CHECK:STDERR: ^ + // CHECK:STDERR: fail_value_disallowed.carbon:[[@LINE-4]]:1: There was no return type provided. + // CHECK:STDERR: fn Main() { + // CHECK:STDERR: ^ return 0; } diff --git a/toolchain/semantics/testdata/return/fail_value_missing.carbon b/toolchain/semantics/testdata/return/fail_value_missing.carbon index 897dd46b085d..062738207cf6 100644 --- a/toolchain/semantics/testdata/return/fail_value_missing.carbon +++ b/toolchain/semantics/testdata/return/fail_value_missing.carbon @@ -35,6 +35,8 @@ // CHECK:STDOUT: ] fn Main() -> i32 { - // CHECK:STDERR: fail_value_missing.carbon:[[@LINE+1]]:9: Must return a i32. + // CHECK:STDERR: fail_value_missing.carbon:[[@LINE+3]]:9: Must return a i32. + // CHECK:STDERR: return; + // CHECK:STDERR: ^ return; } diff --git a/toolchain/semantics/testdata/struct/fail_assign_empty.carbon b/toolchain/semantics/testdata/struct/fail_assign_empty.carbon index da4652b19994..2208abbae191 100644 --- a/toolchain/semantics/testdata/struct/fail_assign_empty.carbon +++ b/toolchain/semantics/testdata/struct/fail_assign_empty.carbon @@ -47,5 +47,7 @@ // CHECK:STDOUT: ], // CHECK:STDOUT: ] -// CHECK:STDERR: fail_assign_empty.carbon:[[@LINE+1]]:22: Cannot implicitly convert from `{} as Type` to `{.a: i32}`. +// CHECK:STDERR: fail_assign_empty.carbon:[[@LINE+3]]:22: Cannot implicitly convert from `{} as Type` to `{.a: i32}`. +// CHECK:STDERR: var x: {.a: i32} = {}; +// CHECK:STDERR: ^ var x: {.a: i32} = {}; diff --git a/toolchain/semantics/testdata/struct/fail_assign_to_empty.carbon b/toolchain/semantics/testdata/struct/fail_assign_to_empty.carbon index 10b412f90be4..c47567241283 100644 --- a/toolchain/semantics/testdata/struct/fail_assign_to_empty.carbon +++ b/toolchain/semantics/testdata/struct/fail_assign_to_empty.carbon @@ -56,5 +56,7 @@ // CHECK:STDOUT: ], // CHECK:STDOUT: ] -// CHECK:STDERR: fail_assign_to_empty.carbon:[[@LINE+1]]:21: Cannot implicitly convert from `{.a: i32}` to `{} as Type`. +// CHECK:STDERR: fail_assign_to_empty.carbon:[[@LINE+3]]:21: Cannot implicitly convert from `{.a: i32}` to `{} as Type`. +// CHECK:STDERR: var x: {} = {.a = 1}; +// CHECK:STDERR: ^ var x: {} = {.a = 1}; diff --git a/toolchain/semantics/testdata/struct/fail_field_name_mismatch.carbon b/toolchain/semantics/testdata/struct/fail_field_name_mismatch.carbon index 0a66968df9d9..3b82e14266f6 100644 --- a/toolchain/semantics/testdata/struct/fail_field_name_mismatch.carbon +++ b/toolchain/semantics/testdata/struct/fail_field_name_mismatch.carbon @@ -60,5 +60,7 @@ // CHECK:STDOUT: ], // CHECK:STDOUT: ] -// CHECK:STDERR: fail_field_name_mismatch.carbon:[[@LINE+1]]:28: Cannot implicitly convert from `{.b: i32}` to `{.a: i32}`. +// CHECK:STDERR: fail_field_name_mismatch.carbon:[[@LINE+3]]:28: Cannot implicitly convert from `{.b: i32}` to `{.a: i32}`. +// CHECK:STDERR: var x: {.a: i32} = {.b = 1}; +// CHECK:STDERR: ^ var x: {.a: i32} = {.b = 1}; diff --git a/toolchain/semantics/testdata/struct/fail_field_type_mismatch.carbon b/toolchain/semantics/testdata/struct/fail_field_type_mismatch.carbon index 4cb1eb9bb265..63352220bb11 100644 --- a/toolchain/semantics/testdata/struct/fail_field_type_mismatch.carbon +++ b/toolchain/semantics/testdata/struct/fail_field_type_mismatch.carbon @@ -61,5 +61,7 @@ // CHECK:STDOUT: ], // CHECK:STDOUT: ] -// CHECK:STDERR: fail_field_type_mismatch.carbon:[[@LINE+1]]:30: Cannot implicitly convert from `{.b: f64}` to `{.a: i32}`. +// CHECK:STDERR: fail_field_type_mismatch.carbon:[[@LINE+3]]:30: Cannot implicitly convert from `{.b: f64}` to `{.a: i32}`. +// CHECK:STDERR: var x: {.a: i32} = {.b = 1.0}; +// CHECK:STDERR: ^ var x: {.a: i32} = {.b = 1.0}; diff --git a/toolchain/semantics/testdata/struct/fail_member_access_type.carbon b/toolchain/semantics/testdata/struct/fail_member_access_type.carbon index ec51789ee6cd..405feab259ba 100644 --- a/toolchain/semantics/testdata/struct/fail_member_access_type.carbon +++ b/toolchain/semantics/testdata/struct/fail_member_access_type.carbon @@ -66,5 +66,7 @@ // CHECK:STDOUT: ] var x: {.a: f64} = {.a = 4.0}; -// CHECK:STDERR: fail_member_access_type.carbon:[[@LINE+1]]:15: Type `{.a: f64}` does not have a member `b`. +// CHECK:STDERR: fail_member_access_type.carbon:[[@LINE+3]]:15: Type `{.a: f64}` does not have a member `b`. +// CHECK:STDERR: var y: i32 = x.b; +// CHECK:STDERR: ^ var y: i32 = x.b; diff --git a/toolchain/semantics/testdata/struct/fail_non_member_access.carbon b/toolchain/semantics/testdata/struct/fail_non_member_access.carbon index 6f9b2c378300..bd63d9be1dab 100644 --- a/toolchain/semantics/testdata/struct/fail_non_member_access.carbon +++ b/toolchain/semantics/testdata/struct/fail_non_member_access.carbon @@ -65,5 +65,7 @@ // CHECK:STDOUT: ] var x: {.a: i32} = {.a = 4}; -// CHECK:STDERR: fail_non_member_access.carbon:[[@LINE+1]]:15: Type `{.a: i32}` does not have a member `b`. +// CHECK:STDERR: fail_non_member_access.carbon:[[@LINE+3]]:15: Type `{.a: i32}` does not have a member `b`. +// CHECK:STDERR: var y: i32 = x.b; +// CHECK:STDERR: ^ var y: i32 = x.b; diff --git a/toolchain/semantics/testdata/struct/fail_too_few_values.carbon b/toolchain/semantics/testdata/struct/fail_too_few_values.carbon index 70ae96b56c45..773289d85a5a 100644 --- a/toolchain/semantics/testdata/struct/fail_too_few_values.carbon +++ b/toolchain/semantics/testdata/struct/fail_too_few_values.carbon @@ -63,5 +63,7 @@ // CHECK:STDOUT: ], // CHECK:STDOUT: ] -// CHECK:STDERR: fail_too_few_values.carbon:[[@LINE+1]]:37: Cannot implicitly convert from `{.a: i32}` to `{.a: i32, .b: i32}`. +// CHECK:STDERR: fail_too_few_values.carbon:[[@LINE+3]]:37: Cannot implicitly convert from `{.a: i32}` to `{.a: i32, .b: i32}`. +// CHECK:STDERR: var x: {.a: i32, .b: i32} = {.a = 1}; +// CHECK:STDERR: ^ var x: {.a: i32, .b: i32} = {.a = 1}; diff --git a/toolchain/semantics/testdata/struct/fail_type_assign.carbon b/toolchain/semantics/testdata/struct/fail_type_assign.carbon index ff408ea00b83..cf8c707e8c08 100644 --- a/toolchain/semantics/testdata/struct/fail_type_assign.carbon +++ b/toolchain/semantics/testdata/struct/fail_type_assign.carbon @@ -47,5 +47,7 @@ // CHECK:STDOUT: ], // CHECK:STDOUT: ] -// CHECK:STDERR: fail_type_assign.carbon:[[@LINE+1]]:29: Cannot implicitly convert from `Type` to `{.a: i32}`. +// CHECK:STDERR: fail_type_assign.carbon:[[@LINE+3]]:29: Cannot implicitly convert from `Type` to `{.a: i32}`. +// CHECK:STDERR: var x: {.a: i32} = {.a: i32}; +// CHECK:STDERR: ^ var x: {.a: i32} = {.a: i32}; diff --git a/toolchain/semantics/testdata/struct/fail_value_as_type.carbon b/toolchain/semantics/testdata/struct/fail_value_as_type.carbon index cbab45c5a63a..73e42a78590f 100644 --- a/toolchain/semantics/testdata/struct/fail_value_as_type.carbon +++ b/toolchain/semantics/testdata/struct/fail_value_as_type.carbon @@ -49,5 +49,7 @@ // CHECK:STDOUT: ], // CHECK:STDOUT: ] -// CHECK:STDERR: fail_value_as_type.carbon:[[@LINE+1]]:15: Cannot implicitly convert from `{.a: i32}` to `Type`. +// CHECK:STDERR: fail_value_as_type.carbon:[[@LINE+3]]:15: Cannot implicitly convert from `{.a: i32}` to `Type`. +// CHECK:STDERR: var x: {.a = 1}; +// CHECK:STDERR: ^ var x: {.a = 1}; diff --git a/toolchain/semantics/testdata/tuples/fail_assign_empty.carbon b/toolchain/semantics/testdata/tuples/fail_assign_empty.carbon index 3d132f87bd81..f9ede548485e 100644 --- a/toolchain/semantics/testdata/tuples/fail_assign_empty.carbon +++ b/toolchain/semantics/testdata/tuples/fail_assign_empty.carbon @@ -59,5 +59,7 @@ // CHECK:STDOUT: ], // CHECK:STDOUT: ] -// CHECK:STDERR: fail_assign_empty.carbon:[[@LINE+1]]:19: Cannot implicitly convert from `() as type` to `(i32,) as type`. +// CHECK:STDERR: fail_assign_empty.carbon:[[@LINE+3]]:19: Cannot implicitly convert from `() as type` to `(i32,) as type`. +// CHECK:STDERR: var x: (i32,) = (); +// CHECK:STDERR: ^ var x: (i32,) = (); diff --git a/toolchain/semantics/testdata/tuples/fail_assign_to_empty.carbon b/toolchain/semantics/testdata/tuples/fail_assign_to_empty.carbon index 206bed32c528..99b15bbf51af 100644 --- a/toolchain/semantics/testdata/tuples/fail_assign_to_empty.carbon +++ b/toolchain/semantics/testdata/tuples/fail_assign_to_empty.carbon @@ -43,5 +43,7 @@ // CHECK:STDOUT: ], // CHECK:STDOUT: ] -// CHECK:STDERR: fail_assign_to_empty.carbon:[[@LINE+1]]:17: Cannot implicitly convert from `i32` to `() as type`. +// CHECK:STDERR: fail_assign_to_empty.carbon:[[@LINE+3]]:17: Cannot implicitly convert from `i32` to `() as type`. +// CHECK:STDERR: var x: () = (66); +// CHECK:STDERR: ^ var x: () = (66); diff --git a/toolchain/semantics/testdata/tuples/fail_element_type_mismatch.carbon b/toolchain/semantics/testdata/tuples/fail_element_type_mismatch.carbon index 469f592e0331..496363ddf454 100644 --- a/toolchain/semantics/testdata/tuples/fail_element_type_mismatch.carbon +++ b/toolchain/semantics/testdata/tuples/fail_element_type_mismatch.carbon @@ -81,5 +81,7 @@ // CHECK:STDOUT: ], // CHECK:STDOUT: ] -// CHECK:STDERR: fail_element_type_mismatch.carbon:[[@LINE+1]]:31: Cannot implicitly convert from `(i32, f64) as type` to `(i32, i32) as type`. +// CHECK:STDERR: fail_element_type_mismatch.carbon:[[@LINE+3]]:31: Cannot implicitly convert from `(i32, f64) as type` to `(i32, i32) as type`. +// CHECK:STDERR: var x: (i32, i32) = (2, 65.89); +// CHECK:STDERR: ^ var x: (i32, i32) = (2, 65.89); diff --git a/toolchain/semantics/testdata/tuples/fail_too_few_element.carbon b/toolchain/semantics/testdata/tuples/fail_too_few_element.carbon index ad5a47a94585..f4cdfe52f5e8 100644 --- a/toolchain/semantics/testdata/tuples/fail_too_few_element.carbon +++ b/toolchain/semantics/testdata/tuples/fail_too_few_element.carbon @@ -73,5 +73,7 @@ // CHECK:STDOUT: ], // CHECK:STDOUT: ] -// CHECK:STDERR: fail_too_few_element.carbon:[[@LINE+1]]:26: Cannot implicitly convert from `(i32,) as type` to `(i32, i32) as type`. +// CHECK:STDERR: fail_too_few_element.carbon:[[@LINE+3]]:26: Cannot implicitly convert from `(i32,) as type` to `(i32, i32) as type`. +// CHECK:STDERR: var x: (i32, i32) = (2, ); +// CHECK:STDERR: ^ var x: (i32, i32) = (2, ); diff --git a/toolchain/semantics/testdata/tuples/fail_type_assign.carbon b/toolchain/semantics/testdata/tuples/fail_type_assign.carbon index 86ecc4980613..86371c4c5110 100644 --- a/toolchain/semantics/testdata/tuples/fail_type_assign.carbon +++ b/toolchain/semantics/testdata/tuples/fail_type_assign.carbon @@ -59,5 +59,7 @@ // CHECK:STDOUT: ], // CHECK:STDOUT: ] -// CHECK:STDERR: fail_type_assign.carbon:[[@LINE+1]]:25: Cannot implicitly convert from `(Type,) as type` to `(i32,) as type`. +// CHECK:STDERR: fail_type_assign.carbon:[[@LINE+3]]:25: Cannot implicitly convert from `(Type,) as type` to `(i32,) as type`. +// CHECK:STDERR: var x: (i32, ) = (i32, ); +// CHECK:STDERR: ^ var x: (i32, ) = (i32, ); diff --git a/toolchain/semantics/testdata/tuples/fail_value_as_type.carbon b/toolchain/semantics/testdata/tuples/fail_value_as_type.carbon index c56721c2b367..e1627278a63e 100644 --- a/toolchain/semantics/testdata/tuples/fail_value_as_type.carbon +++ b/toolchain/semantics/testdata/tuples/fail_value_as_type.carbon @@ -53,5 +53,7 @@ // CHECK:STDOUT: ], // CHECK:STDOUT: ] -// CHECK:STDERR: fail_value_as_type.carbon:[[@LINE+1]]:12: Cannot implicitly convert from `i32` to `Type`. +// CHECK:STDERR: fail_value_as_type.carbon:[[@LINE+3]]:12: Cannot implicitly convert from `i32` to `Type`. +// CHECK:STDERR: var x: (1, ); +// CHECK:STDERR: ^ var x: (1, ); diff --git a/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon b/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon index 74e4b0d608b9..e267bf3ec643 100644 --- a/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon +++ b/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon @@ -57,7 +57,11 @@ fn Main() { var x: i32 = 0; - // CHECK:STDERR: fail_duplicate_decl.carbon:[[@LINE+2]]:7: Duplicate name being declared in the same scope. - // CHECK:STDERR: fail_duplicate_decl.carbon:[[@LINE-2]]:7: Name is previously declared here. + // CHECK:STDERR: fail_duplicate_decl.carbon:[[@LINE+6]]:7: Duplicate name being declared in the same scope. + // CHECK:STDERR: var x: i32 = 0; + // CHECK:STDERR: ^ + // CHECK:STDERR: fail_duplicate_decl.carbon:[[@LINE-4]]:7: Name is previously declared here. + // CHECK:STDERR: var x: i32 = 0; + // CHECK:STDERR: ^ var x: i32 = 0; } diff --git a/toolchain/semantics/testdata/var/fail_init_type_mismatch.carbon b/toolchain/semantics/testdata/var/fail_init_type_mismatch.carbon index 17b66e27387f..6678f9028106 100644 --- a/toolchain/semantics/testdata/var/fail_init_type_mismatch.carbon +++ b/toolchain/semantics/testdata/var/fail_init_type_mismatch.carbon @@ -47,6 +47,8 @@ // CHECK:STDOUT: ] fn Main() { - // CHECK:STDERR: fail_init_type_mismatch.carbon:[[@LINE+1]]:19: Cannot implicitly convert from `f64` to `i32`. + // CHECK:STDERR: fail_init_type_mismatch.carbon:[[@LINE+3]]:19: Cannot implicitly convert from `f64` to `i32`. + // CHECK:STDERR: var x: i32 = 1.0; + // CHECK:STDERR: ^ var x: i32 = 1.0; } diff --git a/toolchain/semantics/testdata/var/fail_init_with_self.carbon b/toolchain/semantics/testdata/var/fail_init_with_self.carbon index 73897436bc61..7c10edda5c9a 100644 --- a/toolchain/semantics/testdata/var/fail_init_with_self.carbon +++ b/toolchain/semantics/testdata/var/fail_init_with_self.carbon @@ -43,6 +43,8 @@ // CHECK:STDOUT: ] fn Main() { - // CHECK:STDERR: fail_init_with_self.carbon:[[@LINE+1]]:16: Name x not found + // CHECK:STDERR: fail_init_with_self.carbon:[[@LINE+3]]:16: Name x not found + // CHECK:STDERR: var x: i32 = x; + // CHECK:STDERR: ^ var x: i32 = x; } diff --git a/toolchain/semantics/testdata/var/fail_lookup_outside_scope.carbon b/toolchain/semantics/testdata/var/fail_lookup_outside_scope.carbon index 67eaf3c1e475..f781edec69a4 100644 --- a/toolchain/semantics/testdata/var/fail_lookup_outside_scope.carbon +++ b/toolchain/semantics/testdata/var/fail_lookup_outside_scope.carbon @@ -51,5 +51,7 @@ fn Main() { var x: i32; } -// CHECK:STDERR: fail_lookup_outside_scope.carbon:[[@LINE+1]]:14: Name x not found +// CHECK:STDERR: fail_lookup_outside_scope.carbon:[[@LINE+3]]:14: Name x not found +// CHECK:STDERR: var y: i32 = x; +// CHECK:STDERR: ^ var y: i32 = x; diff --git a/toolchain/semantics/testdata/var/fail_storage_is_literal.carbon b/toolchain/semantics/testdata/var/fail_storage_is_literal.carbon index 62450fea1299..1ef0748e9c5a 100644 --- a/toolchain/semantics/testdata/var/fail_storage_is_literal.carbon +++ b/toolchain/semantics/testdata/var/fail_storage_is_literal.carbon @@ -49,6 +49,8 @@ // CHECK:STDOUT: ] fn Main() { - // CHECK:STDERR: fail_storage_is_literal.carbon:[[@LINE+1]]:10: Cannot implicitly convert from `i32` to `Type`. + // CHECK:STDERR: fail_storage_is_literal.carbon:[[@LINE+3]]:10: Cannot implicitly convert from `i32` to `Type`. + // CHECK:STDERR: var x: 1 = 1; + // CHECK:STDERR: ^ var x: 1 = 1; }