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-4852] Property modification doesn't take effect #47429

Closed
pushkarnk opened this issue May 10, 2017 · 1 comment
Closed

[SR-4852] Property modification doesn't take effect #47429

pushkarnk opened this issue May 10, 2017 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself

Comments

@pushkarnk
Copy link

Previous ID SR-4852
Radar None
Original Reporter @pushkarnk
Type Bug
Status Closed
Resolution Cannot Reproduce
Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: f7ac911269dbb72104e8be21707022f9

Issue Description:

Here's a simple test program that reproduces a apparently weird problem:

enum State {
    case ready(TState)
    case inProgress(TState)

    var isPaused: Bool {
        switch self {
        case .ready: return false
        case .inProgress: return false
        }
    }
}

enum Drain {
    case foo(String)
    case bar(Int, String)
}

struct TState {
    let drain: Drain
}

class Task {
    var state = State.ready(TState(drain: .foo("wow"))) { 
        willSet {
            if newValue.isPaused { }
        }
    }

    func resume() {
        if case .ready(let tState) = state {
            print("before => \(state)")
            state = .inProgress(tState) //this assignment does not happen
            print("after => \(state)")
        }
    }
}    

//main
Task().resume()

Expected output:

before => ready(Test.TState(drain: Test.Drain.foo("wow")))
after => inProgress(Test.TState(drain: Test.Drain.foo("wow")))

Actual output (with HEAD):

before => ready(Test.TState(drain: Test.Drain.foo("wow")))
after => ready(Test.TState(drain: Test.Drain.foo("wow")))

PS: This issue is blocking a bunch of PRs in Foundation. This problem is not seen in swift-DEVELOPMENT-SNAPSHOT-2017-04-24-a-ubuntu16.04, so it is a regression.

@pushkarnk
Copy link
Author

After updating the repos today, I no longer see this problem.

Just for the record: I do see the problem with swift-DEVELOPMENT-SNAPSHOT-2017-05-09-a

@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 itself
Projects
None yet
Development

No branches or pull requests

1 participant