Skip to content

Commit e1ff0aa

Browse files
committed
SmallProjectionPath: allow parsing an empty path
If the string to parse doesn't start with a token which belongs to a projection path, just return an empty path instead of throwing an error.
1 parent 8f0dd56 commit e1ff0aa

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

SwiftCompilerSources/Sources/SIL/SmallProjectionPath.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ extension StringParser {
471471

472472
mutating func parseProjectionPathFromSIL() throws -> SmallProjectionPath {
473473
var entries: [(SmallProjectionPath.FieldKind, Int)] = []
474-
repeat {
474+
while true {
475475
if consume("**") {
476476
entries.append((.anything, 0))
477477
} else if consume("c*") {
@@ -497,12 +497,10 @@ extension StringParser {
497497
entries.append((.structField, idx))
498498
} else if let tupleElemIdx = consumeInt() {
499499
entries.append((.tupleField, tupleElemIdx))
500-
} else {
501-
try throwError("expected selection path component")
500+
} else if !consume(".") {
501+
return try createPath(from: entries)
502502
}
503-
} while consume(".")
504-
505-
return try createPath(from: entries)
503+
}
506504
}
507505

508506
private func createPath(from entries: [(SmallProjectionPath.FieldKind, Int)]) throws -> SmallProjectionPath {

0 commit comments

Comments
 (0)