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.
This commit is contained in:
Erik Eckstein
2022-09-12 08:18:41 +02:00
parent 8f0dd56066
commit e1ff0aa235

View File

@@ -471,7 +471,7 @@ extension StringParser {
mutating func parseProjectionPathFromSIL() throws -> SmallProjectionPath {
var entries: [(SmallProjectionPath.FieldKind, Int)] = []
repeat {
while true {
if consume("**") {
entries.append((.anything, 0))
} else if consume("c*") {
@@ -497,12 +497,10 @@ extension StringParser {
entries.append((.structField, idx))
} else if let tupleElemIdx = consumeInt() {
entries.append((.tupleField, tupleElemIdx))
} else {
try throwError("expected selection path component")
} else if !consume(".") {
return try createPath(from: entries)
}
} while consume(".")
return try createPath(from: entries)
}
}
private func createPath(from entries: [(SmallProjectionPath.FieldKind, Int)]) throws -> SmallProjectionPath {