Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-5119] "Simultaneous access" error is too strict for access to self in mutating methods #47695

Closed
lilyball mannequin opened this issue Jun 6, 2017 · 6 comments
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@lilyball
Copy link
Mannequin

lilyball mannequin commented Jun 6, 2017

Previous ID SR-5119
Radar rdar://problem/31909639
Original Reporter @lilyball
Type Bug
Status Closed
Resolution Done
Environment

Apple Swift version 4.0 (swiftlang-900.0.43 clang-900.0.22.8)
Target: x86_64-apple-macosx10.9

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee @lilyball
Priority Medium

md5: 19130628523dc9a92b79788f529809d8

Issue Description:

In Swift 3.2 and Swift 4, the new exclusive memory access model is a bit too strict when looking at mutating methods of structs. Mutating methods that mutate two different stored properties of self in the same expression are considered to be in error, even though this is a perfectly normal thing to want to do and should be safe.

For example:

struct Foo {
    mutating func bar() {
        _ = utf8.decode(&iter)
    }

    var utf8 = UTF8()
    var iter: String.UTF8View.Iterator
}

This complains about the utf8.decode(&iter), as this modifies both the utf8 and iter properties. These are stored properties without property observers, so the accesses to the properties are wholly independent.

This affects the PMJSON library.

@belkadan
Copy link
Contributor

belkadan commented Jun 7, 2017

cc @devincoughlin

@belkadan
Copy link
Contributor

belkadan commented Jun 7, 2017

(We usually try not to make special cases for stored vs. computed properties, but there's already been talk of some other exceptions for exclusive access checking.)

@devincoughlin
Copy link
Member

This is tracked by rdar://problem/31909639 internally.

@devincoughlin
Copy link
Member

There is a fix in master in #10235

@devincoughlin
Copy link
Member

This should be fixed in the nightly builds. The fix is included in Xcode Beta 3.

@lilyball
Copy link
Mannequin Author

lilyball mannequin commented Jul 20, 2017

Confirmed fixed. Thanks!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

2 participants