Am I understanding it correctly?
Yes
Is there any way I should be able guess this behavior?
Not really? As Jordan hinted (https://mobile.twitter.com/UINT_MIN/status/1407035602864910340) the setters are nonmutating, which is a strong hint that there are shenanigans going on, but doesn't tell you anything about the shenanigans themselves.
In general the "perform fetch on getter" behaviour is a compromise based on what was possible in the moment. For completeness, the downsides of not using that local variable are that the fetch will be performed multiple times (which is not performant) and one of them may fail due to discontiguous sections (SwiftUI should swallow the error but you'll see logging). It should "work", but it may generate a fault.
I'm hoping these calisthenics won't be necessary in the long arc of history but the talk (and the docs) have to reflect the perils of the moment.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: