You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears to be common practice to violate exclusivity using `Dictionary.subscript._modify` in a way that the compiler fails to diagnose.
I'm not too concerned about miscompiles yet. But I don't know how to plug this hole before it becomes bigger without possibly breaking a bunch of source. And I don't know how developers should fix their code without sticking silly 'let's in that defeat the purpose of the 'autoclosure'.
Exclusivity violations could also become apparent after inlining if we don't change anything.
It seems common to access a dictionary that is a struct stored property, and reference the same struct, or one of its members in the `defaultValue:` autoclosure.
In most cases, the violation should be harmless, ignoring possible compiler optimization. On the other hand, if we don't diagnose it, then the user could reentrantly access the dictionary in the middle of key insertion...
Nothing comes to mind. We can't fall back on dynamic enforcement since methods like getValue will be compiled on the premise that struct members don't need that. In general, I think we just have to acknowledge this as a bug that we have little choice but to fix. Users will need to factor the autoclosure in a way that doesn't need all of self; in your example, they could make getValue() a static method.