Skip to content

Commit 082a293

Browse files
[Diagnostics] Update compiler diagnostics to use less jargon. (swiftlang#31384)
Fixes rdar://problem/62375243.
1 parent edafa4d commit 082a293

File tree

184 files changed

+556
-556
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+556
-556
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -795,19 +795,19 @@ ERROR(unspaced_unary_operator,none,
795795
"unary operators must not be juxtaposed; parenthesize inner expression",
796796
())
797797

798-
ERROR(use_unresolved_identifier,none,
799-
"use of unresolved %select{identifier|operator}1 %0", (DeclNameRef, bool))
800-
ERROR(use_unresolved_identifier_corrected,none,
801-
"use of unresolved %select{identifier|operator}1 %0; did you mean '%2'?",
798+
ERROR(cannot_find_in_scope,none,
799+
"cannot %select{find|find operator}1 %0 in scope", (DeclNameRef, bool))
800+
ERROR(cannot_find_in_scope_corrected,none,
801+
"cannot %select{find|find operator}1 %0 in scope; did you mean '%2'?",
802802
(DeclNameRef, bool, StringRef))
803803
NOTE(confusable_character,none,
804804
"%select{identifier|operator}0 '%1' contains possibly confused characters; "
805805
"did you mean to use '%2'?",
806806
(bool, StringRef, StringRef))
807-
ERROR(use_undeclared_type,none,
808-
"use of undeclared type %0", (DeclNameRef))
809-
ERROR(use_undeclared_type_did_you_mean,none,
810-
"use of undeclared type %0; did you mean to use '%1'?", (DeclNameRef, StringRef))
807+
ERROR(cannot_find_type_in_scope,none,
808+
"cannot find type %0 in scope", (DeclNameRef))
809+
ERROR(cannot_find_type_in_scope_did_you_mean,none,
810+
"cannot find type %0 in scope; did you mean to use '%1'?", (DeclNameRef, StringRef))
811811
NOTE(note_typo_candidate_implicit_member,none,
812812
"did you mean the implicitly-synthesized %1 '%0'?", (StringRef, StringRef))
813813
NOTE(note_remapped_type,none,
@@ -3669,9 +3669,9 @@ ERROR(continue_not_in_this_stmt,none,
36693669
"'continue' cannot be used with %0 statements", (StringRef))
36703670

36713671
ERROR(unresolved_label,none,
3672-
"use of unresolved label %0", (Identifier))
3672+
"cannot find label %0 in scope", (Identifier))
36733673
ERROR(unresolved_label_corrected,none,
3674-
"use of unresolved label %0; did you mean %1?",
3674+
"cannot find label %0 in scope; did you mean %1?",
36753675
(Identifier, Identifier))
36763676

36773677
ERROR(foreach_sequence_does_not_conform_to_expected_protocol,none,

lib/Sema/PCMacro.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ class Instrumenter : InstrumenterBase {
575575
Context, BeforeLoggerRef, ArgsWithSourceRange, ArgLabels);
576576
Added<ApplyExpr *> AddedBeforeLogger(BeforeLoggerCall);
577577
if (!doTypeCheck(Context, TypeCheckDC, AddedBeforeLogger)) {
578-
// typically due to 'use of unresolved identifier '__builtin_pc_before''
578+
// typically due to 'cannot find '__builtin_pc_before' in scope'
579579
return E; // return E, it will be used in recovering from TC failure
580580
}
581581

@@ -587,7 +587,7 @@ class Instrumenter : InstrumenterBase {
587587
Context, AfterLoggerRef, ArgsWithSourceRange, ArgLabels);
588588
Added<ApplyExpr *> AddedAfterLogger(AfterLoggerCall);
589589
if (!doTypeCheck(Context, TypeCheckDC, AddedAfterLogger)) {
590-
// typically due to 'use of unresolved identifier '__builtin_pc_after''
590+
// typically due to 'cannot find '__builtin_pc_after' in scope'
591591
return E; // return E, it will be used in recovering from TC failure
592592
}
593593

lib/Sema/TypeCheckAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3671,7 +3671,7 @@ static AbstractFunctionDecl *findAbstractFunctionDecl(
36713671

36723672
// Otherwise, emit the appropriate diagnostic and return nullptr.
36733673
if (results.empty()) {
3674-
ctx.Diags.diagnose(funcNameLoc, diag::use_unresolved_identifier, funcName,
3674+
ctx.Diags.diagnose(funcNameLoc, diag::cannot_find_in_scope, funcName,
36753675
funcName.isOperator());
36763676
return nullptr;
36773677
}

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ static bool diagnoseRangeOperatorMisspell(DiagnosticEngine &Diags,
392392

393393
if (!corrected.empty()) {
394394
Diags
395-
.diagnose(UDRE->getLoc(), diag::use_unresolved_identifier_corrected,
395+
.diagnose(UDRE->getLoc(), diag::cannot_find_in_scope_corrected,
396396
UDRE->getName(), true, corrected)
397397
.highlight(UDRE->getSourceRange())
398398
.fixItReplace(UDRE->getSourceRange(), corrected);
@@ -416,7 +416,7 @@ static bool diagnoseIncDecOperator(DiagnosticEngine &Diags,
416416

417417
if (!corrected.empty()) {
418418
Diags
419-
.diagnose(UDRE->getLoc(), diag::use_unresolved_identifier_corrected,
419+
.diagnose(UDRE->getLoc(), diag::cannot_find_in_scope_corrected,
420420
UDRE->getName(), true, corrected)
421421
.highlight(UDRE->getSourceRange());
422422

@@ -537,7 +537,7 @@ Expr *TypeChecker::resolveDeclRefExpr(UnresolvedDeclRefExpr *UDRE,
537537

538538
auto emitBasicError = [&] {
539539
Context.Diags
540-
.diagnose(Loc, diag::use_unresolved_identifier, Name,
540+
.diagnose(Loc, diag::cannot_find_in_scope, Name,
541541
Name.isOperator())
542542
.highlight(UDRE->getSourceRange());
543543
};
@@ -561,7 +561,7 @@ Expr *TypeChecker::resolveDeclRefExpr(UnresolvedDeclRefExpr *UDRE,
561561

562562
if (auto typo = corrections.claimUniqueCorrection()) {
563563
auto diag = Context.Diags.diagnose(
564-
Loc, diag::use_unresolved_identifier_corrected, Name,
564+
Loc, diag::cannot_find_in_scope_corrected, Name,
565565
Name.isOperator(), typo->CorrectedName.getBaseIdentifier().str());
566566
diag.highlight(UDRE->getSourceRange());
567567
typo->addFixits(diag);

lib/Sema/TypeCheckExprObjC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ Optional<Type> TypeChecker::checkObjCKeyPathExpr(DeclContext *dc,
263263
diags.diagnose(componentNameLoc, diag::could_not_find_type_member,
264264
currentType, componentName);
265265
else
266-
diags.diagnose(componentNameLoc, diag::use_unresolved_identifier,
266+
diags.diagnose(componentNameLoc, diag::cannot_find_in_scope,
267267
componentName, false);
268268

269269
// Note all the correction candidates.

lib/Sema/TypeCheckType.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ static Type diagnoseUnknownType(TypeResolution resolution,
11411141
auto I = Remapped.find(TypeName);
11421142
if (I != Remapped.end()) {
11431143
auto RemappedTy = I->second->getString();
1144-
diags.diagnose(L, diag::use_undeclared_type_did_you_mean,
1144+
diags.diagnose(L, diag::cannot_find_type_in_scope_did_you_mean,
11451145
comp->getNameRef(), RemappedTy)
11461146
.highlight(R)
11471147
.fixItReplace(R, RemappedTy);
@@ -1158,7 +1158,7 @@ static Type diagnoseUnknownType(TypeResolution resolution,
11581158
return I->second;
11591159
}
11601160

1161-
diags.diagnose(L, diag::use_undeclared_type,
1161+
diags.diagnose(L, diag::cannot_find_type_in_scope,
11621162
comp->getNameRef())
11631163
.highlight(R);
11641164

@@ -1654,7 +1654,7 @@ Type TypeChecker::resolveIdentifierType(
16541654
if (!options.contains(TypeResolutionFlags::SilenceErrors)) {
16551655
auto moduleName = moduleTy->getModule()->getName();
16561656
diags.diagnose(Components.back()->getNameLoc(),
1657-
diag::use_undeclared_type, DeclNameRef(moduleName));
1657+
diag::cannot_find_type_in_scope, DeclNameRef(moduleName));
16581658
diags.diagnose(Components.back()->getNameLoc(),
16591659
diag::note_module_as_type, moduleName);
16601660
}

test/APINotes/versioned.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func testRenamedUnknownEnum() {
158158
}
159159

160160
func testRenamedTrueEnum() {
161-
// CHECK-DIAGS: [[@LINE+1]]:7: error: use of unresolved identifier 'TrueEnumValue'
161+
// CHECK-DIAGS: [[@LINE+1]]:7: error: cannot find 'TrueEnumValue' in scope
162162
_ = TrueEnumValue
163163

164164
// CHECK-DIAGS: [[@LINE+1]]:16: error: type 'TrueEnum' has no member 'TrueEnumValue'
@@ -169,7 +169,7 @@ func testRenamedTrueEnum() {
169169

170170
_ = TrueEnum.value // okay
171171

172-
// CHECK-DIAGS: [[@LINE+1]]:7: error: use of unresolved identifier 'TrueEnumRenamed'
172+
// CHECK-DIAGS: [[@LINE+1]]:7: error: cannot find 'TrueEnumRenamed' in scope
173173
_ = TrueEnumRenamed
174174

175175
// CHECK-DIAGS: [[@LINE+1]]:16: error: type 'TrueEnum' has no member 'TrueEnumRenamed'
@@ -190,7 +190,7 @@ func testRenamedTrueEnum() {
190190
_ = TrueEnum.renamedSwift4
191191
// CHECK-DIAGS-4-NOT: :[[@LINE-1]]:16:
192192

193-
// CHECK-DIAGS: [[@LINE+1]]:7: error: use of unresolved identifier 'TrueEnumAliasRenamed'
193+
// CHECK-DIAGS: [[@LINE+1]]:7: error: cannot find 'TrueEnumAliasRenamed' in scope
194194
_ = TrueEnumAliasRenamed
195195

196196
// CHECK-DIAGS: [[@LINE+1]]:16: error: type 'TrueEnum' has no member 'TrueEnumAliasRenamed'
@@ -213,7 +213,7 @@ func testRenamedTrueEnum() {
213213
}
214214

215215
func testRenamedOptionyEnum() {
216-
// CHECK-DIAGS: [[@LINE+1]]:7: error: use of unresolved identifier 'OptionyEnumValue'
216+
// CHECK-DIAGS: [[@LINE+1]]:7: error: cannot find 'OptionyEnumValue' in scope
217217
_ = OptionyEnumValue
218218

219219
// CHECK-DIAGS: [[@LINE+1]]:19: error: type 'OptionyEnum' has no member 'OptionyEnumValue'
@@ -224,7 +224,7 @@ func testRenamedOptionyEnum() {
224224

225225
_ = OptionyEnum.value // okay
226226

227-
// CHECK-DIAGS: [[@LINE+1]]:7: error: use of unresolved identifier 'OptionyEnumRenamed'
227+
// CHECK-DIAGS: [[@LINE+1]]:7: error: cannot find 'OptionyEnumRenamed' in scope
228228
_ = OptionyEnumRenamed
229229

230230
// CHECK-DIAGS: [[@LINE+1]]:19: error: type 'OptionyEnum' has no member 'OptionyEnumRenamed'

test/AutoDiff/Sema/DerivedConformances/class_differentiable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ where T: Differentiable {}
490490

491491
// TF-265: Test invalid initializer (that uses a non-existent type).
492492
class InvalidInitializer: Differentiable {
493-
init(filterShape: (Int, Int, Int, Int), blah: NonExistentType) {} // expected-error {{use of undeclared type 'NonExistentType'}}
493+
init(filterShape: (Int, Int, Int, Int), blah: NonExistentType) {} // expected-error {{cannot find type 'NonExistentType' in scope}}
494494
}
495495

496496
// Test memberwise initializer synthesis.

test/AutoDiff/Sema/DerivedConformances/struct_differentiable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ where T: Differentiable {}
308308

309309
// TF-265: Test invalid initializer (that uses a non-existent type).
310310
struct InvalidInitializer: Differentiable {
311-
init(filterShape: (Int, Int, Int, Int), blah: NonExistentType) {} // expected-error {{use of undeclared type 'NonExistentType'}}
311+
init(filterShape: (Int, Int, Int, Int), blah: NonExistentType) {} // expected-error {{cannot find type 'NonExistentType' in scope}}
312312
}
313313

314314
// Test memberwise initializer synthesis.

test/AutoDiff/Sema/derivative_attr_type_checking.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ func vjpSubtractWrt1(x: Float, y: Float) -> (value: Float, pullback: (Float) ->
7070

7171
// Test invalid original function.
7272

73-
// expected-error @+1 {{use of unresolved identifier 'nonexistentFunction'}}
73+
// expected-error @+1 {{cannot find 'nonexistentFunction' in scope}}
7474
@derivative(of: nonexistentFunction)
7575
func vjpOriginalFunctionNotFound(_ x: Float) -> (value: Float, pullback: (Float) -> Float) {
7676
fatalError()
7777
}
7878

7979
// Test `@derivative` attribute where `value:` result does not conform to `Differentiable`.
8080
// Invalid original function should be diagnosed first.
81-
// expected-error @+1 {{use of unresolved identifier 'nonexistentFunction'}}
81+
// expected-error @+1 {{cannot find 'nonexistentFunction' in scope}}
8282
@derivative(of: nonexistentFunction)
8383
func vjpOriginalFunctionNotFound2(_ x: Float) -> (value: Int, pullback: (Float) -> Float) {
8484
fatalError()

0 commit comments

Comments
 (0)