When will the Swift compiler handle compile errors in Result Builders properly?

Writing code that uses result builders, which is SwiftUI for most people, but also includes Reducers in code using the Point-Free Composable Architecture has become almost untenable. The compiler gives you a single useless error for the first line of the result builder and you have no clue where the actual error is.

The only way to find the actual error(s) is via a type of binary search or bisect, where you comment out half the code in turn to find out if the error still appears, and then successively smaller chunks until you finally have the block of code that is causing the error, and you can then analyse it line by line until you figure out the error yourself.

It's absolutely maddening :cry:

10 Likes

I've literally spent the last 2 hours trying to get a SwiftUI View to compile after some refactoring. The top level view is a ScrollView and the error I was getting was something like "ambiguous call to init" for the ScrollView. I belatedly figured out that removing the ScrollView got me close to the real problem.
But I was also misled by errors appearing on 2 views which it turns out were fine, but for some reason they were showing an error due to the real error further down in the view body.
Of course for every change you have to build (wait 20-30s at least) to see if it's fixed and it's just soul destroying.

1 Like