Skip to content

Commit b79c7b6

Browse files
committed
[ModuleInterface] Update wording of the "failed to build module" error
The error shown when the compiler fails to build a module from its textual interface has been creating some confusion. This is a proposal to make it more useful to the programmer not working in the SDK, insist on looking at the previous errors first, put less emphasis on possible compiler bugs, and always show alternatives to the incompatible compilers issue as this is the most common case now.
1 parent f668c59 commit b79c7b6

File tree

6 files changed

+15
-16
lines changed

6 files changed

+15
-16
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -719,11 +719,10 @@ ERROR(sema_opening_import,Fatal,
719719
ERROR(serialization_load_failed,Fatal,
720720
"failed to load module '%0'", (StringRef))
721721
ERROR(module_interface_build_failed,Fatal,
722-
"failed to %select{build module '%1' from its module interface|verify "
723-
"module interface of '%1'}0; %select{the compiler that produced it, "
724-
"'%3', may have used features that aren't supported by this compiler, "
725-
"'%4'|it may have been damaged or it may have triggered a bug in the "
726-
"Swift compiler when it was produced}2",
722+
"failed to %select{build module '%1' for importation|"
723+
"verify module interface of '%1'}0 due to the errors above; "
724+
"the textual interface may be broken by project issues"
725+
"%select{, differences between compilers (the producer '%3' and this compiler '%4')|}2 or a compiler bug",
727726
(bool, StringRef, bool, StringRef, StringRef))
728727
ERROR(serialization_malformed_module,Fatal,
729728
"malformed compiled module: %0", (StringRef))

test/ModuleInterface/ModuleCache/module-cache-diagnostics.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@
5757
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
5858
// RUN: %FileCheck %s -check-prefix=CHECK-ERROR <%t/err.txt
5959
// CHECK-ERROR: LeafModule.swiftinterface:7:8: error: no such module 'NotAModule'
60-
// CHECK-ERROR: OtherModule.swiftinterface:4:8: error: failed to build module 'LeafModule' from its module interface; it may have been damaged or it may have triggered a bug in the Swift compiler when it was produced
61-
// CHECK-ERROR: module-cache-diagnostics.swift:{{[0-9]+}}:8: error: failed to build module 'OtherModule' from its module interface; it may have been damaged or it may have triggered a bug in the Swift compiler when it was produced
60+
// CHECK-ERROR: OtherModule.swiftinterface:4:8: error: failed to build module 'LeafModule' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug
61+
// CHECK-ERROR: module-cache-diagnostics.swift:{{[0-9]+}}:8: error: failed to build module 'OtherModule' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug
6262
// CHECK-ERROR-NOT: error:
6363
//
6464
//
@@ -82,8 +82,8 @@
8282
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
8383
// RUN: %FileCheck %s -check-prefix=CHECK-ERROR-INLINE <%t/err-inline.txt
8484
// CHECK-ERROR-INLINE: LeafModule.swiftinterface:6:33: error: cannot find 'unresolved' in scope
85-
// CHECK-ERROR-INLINE: OtherModule.swiftinterface:4:8: error: failed to build module 'LeafModule' from its module interface; it may have been damaged or it may have triggered a bug in the Swift compiler when it was produced
86-
// CHECK-ERROR-INLINE: module-cache-diagnostics.swift:{{[0-9]+}}:8: error: failed to build module 'OtherModule' from its module interface; it may have been damaged or it may have triggered a bug in the Swift compiler when it was produced
85+
// CHECK-ERROR-INLINE: OtherModule.swiftinterface:4:8: error: failed to build module 'LeafModule' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug
86+
// CHECK-ERROR-INLINE: module-cache-diagnostics.swift:{{[0-9]+}}:8: error: failed to build module 'OtherModule' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug
8787
// CHECK-ERROR-INLINE-NOT: error:
8888
//
8989
//

test/ModuleInterface/invalid-opaque-result-types.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919

2020
// CHECK: cannot find type 'InvalidParameter' in scope
2121
// CHECK: unable to resolve type for _opaqueReturnTypeOf attribute
22-
// CHECK: failed to build module 'InvalidOpaqueResultType' from its module interface
22+
// CHECK: failed to build module 'InvalidOpaqueResultType' for importation
2323
import InvalidOpaqueResultType

test/ModuleInterface/unbuildable.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626

2727
#if CURRENT
2828
import UnbuildableCurrent
29-
// CURRENT: unbuildable.swift:[[@LINE-1]]:8: error: failed to build module 'UnbuildableCurrent' from its module interface; it may have been damaged or it may have triggered a bug in the Swift compiler when it was produced
29+
// CURRENT: unbuildable.swift:[[@LINE-1]]:8: error: failed to build module 'UnbuildableCurrent' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug
3030
#else
3131
import UnbuildableFuture
32-
// FUTURE: unbuildable.swift:[[@LINE-1]]:8: error: failed to build module 'UnbuildableFuture' from its module interface; the compiler that produced it, 'NeoTokyoSwift 2000.42', may have used features that aren't supported by this compiler, '{{.*Swift version.*}}'
32+
// FUTURE: unbuildable.swift:[[@LINE-1]]:8: error: failed to build module 'UnbuildableFuture' for importation due to the errors above; the textual interface may be broken by project issues, differences between compilers (the producer 'NeoTokyoSwift 2000.42' and this compiler '{{.*Swift version.*}}') or a compiler bug
3333
#endif
3434

35-
// CURRENT-VERIFY: UnbuildableCurrent.swiftinterface:1:1: error: failed to verify module interface of 'UnbuildableCurrent'; it may have been damaged or it may have triggered a bug in the Swift compiler when it was produced
36-
// FUTURE-VERIFY: UnbuildableFuture.swiftinterface:1:1: error: failed to verify module interface of 'UnbuildableFuture'; the compiler that produced it, 'NeoTokyoSwift 2000.42', may have used features that aren't supported by this compiler, '{{.*Swift version.*}}'
35+
// CURRENT-VERIFY: UnbuildableCurrent.swiftinterface:1:1: error: failed to verify module interface of 'UnbuildableCurrent' due to the errors above; the textual interface may be broken by project issues or a compiler bug
36+
// FUTURE-VERIFY: UnbuildableFuture.swiftinterface:1:1: error: failed to verify module interface of 'UnbuildableFuture' due to the errors above; the textual interface may be broken by project issues, differences between compilers (the producer 'NeoTokyoSwift 2000.42' and this compiler '{{.*Swift version.*}}') or a compiler bug

test/ModuleInterface/verify-module-interfaces.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
public struct MyStruct {}
1313

1414
// CHECK: MyModule.swiftinterface:{{[0-9]+}}:{{[0-9]+}}: error: use of unknown directive '#__debug_emit_invalid_swiftinterface_syntax__'
15-
// CHECK: MyModule.swiftinterface:{{[0-9]+}}:{{[0-9]+}}: error: failed to verify module interface of 'MyModule'; it may have been damaged or it may have triggered a bug in the Swift compiler when it was produced
15+
// CHECK: MyModule.swiftinterface:{{[0-9]+}}:{{[0-9]+}}: error: failed to verify module interface of 'MyModule' due to the errors above; the textual interface may be broken by project issues or a compiler bug

validation-test/ParseableInterface/failing-overlay.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
import ImportsOverlay
55

6-
// CHECK: HasOverlay.swiftinterface:1:1: error: failed to build module 'HasOverlay' from its module interface; the compiler that produced it, '(unspecified, file possibly handwritten)', may have used features that aren't supported by this compiler, '{{.*}}Swift version{{.*}}'
6+
// CHECK: HasOverlay.swiftinterface:1:1: error: failed to build module 'HasOverlay' for importation due to the errors above; the textual interface may be broken by project issues, differences between compilers (the producer '(unspecified, file possibly handwritten)' and this compiler '{{.*Swift version.*}}') or a compiler bug

0 commit comments

Comments
 (0)