Skip to content

Commit 342df97

Browse files
committed
Put freestanding init decls in a test into a type.
Even though these aren't semantically valid Swift, these parse correctly with the 9/26 snapshot we're currently on. At a more recent commit we noticed that these `init`s seem to be hitting a code path that causes an assertion in the parser: assertion failed in swift::Type swift::ValueDecl::getInterfaceType() const: ctx.getLegacyGlobalTypeChecker() && "The type checker must be installed to make semantic queries!" We should try to pinpoint this crash, but for now I'm patching this so that the test is more "correct" and it unblocks some of our internal work.
1 parent 116f1f9 commit 342df97

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

Tests/SwiftFormatRulesTests/ValidateDocumentationCommentsTests.swift

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -187,28 +187,30 @@ public class ValidateDocumentationCommentsTests: DiagnosingTestCase {
187187
public func testInitializer() {
188188
let input =
189189
"""
190-
/// Brief summary.
191-
///
192-
/// - Parameter command: The command to execute in the shell environment.
193-
/// - Returns: Shouldn't be here.
194-
init(label commando: String) {
195-
// ...
196-
}
197-
198-
/// Brief summary.
199-
///
200-
/// - Parameter command: The command to execute in the shell environment.
201-
init(label command: String) {
202-
// ...
203-
}
204-
205-
/// Brief summary.
206-
///
207-
/// - Parameters:
208-
/// - command: The command to execute in the shell environment.
209-
/// - stdin: The string to use as standard input.
210-
init(label command: String, label2 stdin: String) {
211-
// ...
190+
struct SomeType {
191+
/// Brief summary.
192+
///
193+
/// - Parameter command: The command to execute in the shell environment.
194+
/// - Returns: Shouldn't be here.
195+
init(label commando: String) {
196+
// ...
197+
}
198+
199+
/// Brief summary.
200+
///
201+
/// - Parameter command: The command to execute in the shell environment.
202+
init(label command: String) {
203+
// ...
204+
}
205+
206+
/// Brief summary.
207+
///
208+
/// - Parameters:
209+
/// - command: The command to execute in the shell environment.
210+
/// - stdin: The string to use as standard input.
211+
init(label command: String, label2 stdin: String) {
212+
// ...
213+
}
212214
}
213215
"""
214216
performLint(ValidateDocumentationComments.self, input: input)

0 commit comments

Comments
 (0)