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-12341] @propertyWrapper wrong behaviour #54775

Open
swift-ci opened this issue Mar 10, 2020 · 1 comment
Open

[SR-12341] @propertyWrapper wrong behaviour #54775

swift-ci opened this issue Mar 10, 2020 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-12341
Radar rdar://problem/60832285
Original Reporter Nostromo (JIRA User)
Type Bug
Environment

Xcode: Version 11.3.1 (11C504)
Swift: Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: cbb8599608eb9f716cf415a3616fff97

is duplicated by:

  • SR-12430 self in Property Wrapper Using Enclosing Self Escapes Before Initialization Completed

Issue Description:

For some reason the following code produces:

SomeSubClass init
subWillSet -  105553175052640 123 321
SomeSuperClass init

It seems that the @propertyWrapper can at some point access an uninitialized memory area.

@propertyWrapper
struct SomeWrapper {

    private var someValue: Int
    var wrappedValue: Int {
        get { someValue }
        set { someValue = newValue }
    }

    init(wrappedValue: Int) {
        someValue = wrappedValue
    }

}

class SomeSuperClass {

    @SomeWrapper var superProperty: Int

    init() {
        print("SomeSuperClass init")
        superProperty = 1
    }

}

final class SomeSubClass: SomeSuperClass {

    @SomeWrapper var subProperty: Int = 123 {
        willSet {
            print("subWillSet - ", superProperty, subProperty, newValue)
        }
    }

    override init() {
        print("SomeSubClass init")
        subProperty = 321
        super.init()
    }

}

let testObject = SomeSubClass()
@beccadax
Copy link
Contributor

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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