swiftlang / swift

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

[SR-15333] Compiler error when property wrapper depends on captured property wrapper #57655

Open Gotyanov opened 2 years ago

Gotyanov commented 2 years ago
Previous ID SR-15333
Radar None
Original Reporter @Gotyanov
Type Bug
Environment Xcode 13 swift-5.5-DEVELOPMENT-SNAPSHOT-2021-10-07-a swift-DEVELOPMENT-SNAPSHOT-2021-10-05-a
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 1 | |Component/s | Compiler | |Labels | Bug, PropertyWrappers | |Assignee | None | |Priority | Medium | md5: ebf0aee26afa5ee4ff03530cc7f90e02

Issue Description:

minimal code to reproduce:

@propertyWrapper
struct Wrapper<Value> {
    var wrappedValue: Value
}

struct A {}
struct B { var a: A }

func test() {
    @Wrapper var a = A() // error: Closure captures '_a' before it is declared

    func makeB() -> B {
        @Wrapper var b = B(a: a)
        return b
    }
}
slavaryk commented 1 year ago

Got the same issue((