3 ms·
The problems with diagnostics are not Xcode’s fault but rather limitations of the Swift compiler diagnostics engine. The original design dating back to Swift 1.
by slavapestov 7y ago
The problems with diagnostics are not Xcode’s fault but rather limitations of the Swift compiler diagnostics engine. The original design dating back to Swift 1.0 has the constraint solver basically produce a success or failure result; in the failure case the type checker would then go and re-type check different subexpressions and try to piece together the types to figure out what went wrong.
This was complex and somewhat tricky to get right, which is why sometimes you see errors that seemingly have nothing to do with the original problem. Closures and generics were especially problematic for the old design to deal with.
Since Swift 4.2 there has been an ongoing effort to rewrite diagnostics so that the solver keeps enough breadcrumbs from failed constraints to piece together an accurate error message. On the master branch the type checker’s test suite has lots of examples where diagnostics have improved significantly.
- Razengan 7y ago> The problems with diagnostics are not Xcode’s fault but rather limitations of the Swift compiler diagnostics engine. True: https://swift.org/blog/new-diagnostic-arch-overview/ https://swift.org/blog/new-diagnostic-arch-overview/