[SR-11297] Swift should not synthesize an access to "oldValue" when it is not needed #53698
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Additional Detail from JIRA
md5: 3f22e40eb4a8f49d81a065a43dfe9a31
duplicates:
Issue Description:
Consider a property wrapper like so:
And a use case like so:
The program will crash at runtime in `Delayed.wrappedValue.get` because the synthesized setter starts by creating the implicit `oldValue` variable and accesses the wrapped value before it is initialized.
There was a short discussion on Twitter about this scenario and @jckarter suggested improving the compiler by having it not synthesizing an access to the variable if `oldValue` is never referenced in the `didSet` body.
That sounds like a great solution to this problem.
The text was updated successfully, but these errors were encountered: