From 72cbea678a823f247f71dffd754bf5c795989b76 Mon Sep 17 00:00:00 2001 From: Hamish Knight Date: Thu, 18 Jan 2024 14:52:20 +0000 Subject: [PATCH] [Sema] Avoid mentioning `then` in a diagnostic This is still an experimental feature, so avoid mentioning it in this diagnostic. --- include/swift/AST/DiagnosticsSema.def | 3 +-- lib/Sema/MiscDiagnostics.cpp | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/swift/AST/DiagnosticsSema.def b/include/swift/AST/DiagnosticsSema.def index 2152cb40cbb01..e5b4cd93cedf5 100644 --- a/include/swift/AST/DiagnosticsSema.def +++ b/include/swift/AST/DiagnosticsSema.def @@ -1274,8 +1274,7 @@ ERROR(single_value_stmt_branch_empty,none, "expected expression in branch of '%0' expression", (StmtKind)) ERROR(single_value_stmt_branch_must_end_in_result,none, - "non-expression branch of '%0' expression may only end with a 'throw' " - "or 'then'", + "non-expression branch of '%0' expression may only end with a 'throw'", (StmtKind)) ERROR(cannot_jump_in_single_value_stmt,none, "cannot '%0' in '%1' when used as expression", diff --git a/lib/Sema/MiscDiagnostics.cpp b/lib/Sema/MiscDiagnostics.cpp index f931a8b15695e..34e2943ed75b0 100644 --- a/lib/Sema/MiscDiagnostics.cpp +++ b/lib/Sema/MiscDiagnostics.cpp @@ -3938,6 +3938,8 @@ class SingleValueStmtUsageChecker final : public ASTWalker { continue; } } + // TODO: If 'then' statements are enabled by default, the wording of + // this diagnostic should be tweaked. Diags.diagnose(branch->getEndLoc(), diag::single_value_stmt_branch_must_end_in_result, S->getKind());