Replies: 2 comments 2 replies
-
I got a similar error in a production app where Xcode 15.1/Swift 5.9.2 can infer the type just fine, while Xcode 15.4/Swift 5.10 can't. I wonder if there's a way to flatten the parser builder expressions? The inferred type is this in our case:
From this expression: Many(0..., into: JSONFlatObject()) { object, pair in
let (name, value) = pair
object[name] = value
} decumulator: { object in
object.keys
.map { key -> (String, JSONScalar) in
return ("\(key)", object[key]!)
}
.reversed()
.makeIterator()
} element: {
Whitespace(0...).noPrinting()
JSONStringParser()
.prettyPrinter(printOptions) {
JSONStringParser(printOptions: printOptions.indented())
}
Whitespace(0...).noPrinting()
":".utf8
.prettyPrinter(printOptions) { ": ".utf8 }
Whitespace(0...).noPrinting()
JSONScalarParser()
Whitespace(0...).noPrinting()
} separator: {
",".utf8
} terminator: {
Parse {
OneOf {
",".utf8
Whitespace(0...)
}
.noPrinting()
Whitespace(0...).noPrinting()
"}".utf8
.prettyPrinter(printOptions) {
("\n" + printOptions.indentation + "}").utf8
}
}
} |
Beta Was this translation helpful? Give feedback.
-
Hi @DivineDominion and @BjornRuud, as far as I can tell this was fixed in #355. We just needed to add a type annotation to get it compiling again, and it now compiles just fine for me in 16.0 and 16.1. Do you have an example of a parser that does not compile in Xcode 16?
Just as with SwiftUI, you can break these parsers into smaller ones. For example, the I am going to convert this to a discussion since I am not sure it is an issue anymore. Let's continue the conversation over there. |
Beta Was this translation helpful? Give feedback.
-
The benchmark will not compile with Xcode 16, it fails in JSON.swift (latest on main):
swift-parsing/Sources/swift-parsing-benchmark/JSON.swift
Line 71 in 82f10fc
Beta Was this translation helpful? Give feedback.
All reactions