swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.28k stars 10.33k forks source link

[SR-11067] Property Wrappers and private breaks #53459

Open swift-ci opened 5 years ago

swift-ci commented 5 years ago
Previous ID SR-11067
Radar None
Original Reporter chriseidhof (JIRA User)
Type Bug
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, CompilerCrash, PropertyWrappers | |Assignee | None | |Priority | Medium | md5: 8bbcb160b8cab5f0d8c7b0f7cbaffb3d

Issue Description:

Here's a minimal example that segfaults:

@propertyWrapper class KeychainItem {
    var wrappedValue: String? = nil
}

struct ContentView : View {
    @KeychainItem private var item: String?
    var body: some View {
        Text("Hello World")
    }
}

Removing the private modifier makes the code compile again.

BTW, the diagnostics for the segfault didn't point to this location. It took quite some time to find the culprit.

swift-ci commented 5 years ago

Comment by Chris Eidhof (JIRA)

Here's a similar bug, without the private modifier (but using a class):

@propertyWrapper class KeychainItem {
    var wrappedValue: String? = nil
}

class Session {
    @KeychainItem var sid: String?
}

struct ContentView : View {
    let session = Session()
    var body: some View {
        Text("Hello World")
    }
}

If we change Session to be a struct it compiles fine...

belkadan commented 5 years ago

The first one's fixed in master and the 5.1 branch. The second one doesn't seem to be crashing for me?