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-7709] didSet values are incorrect when using KeyPaths #50249

Closed
swift-ci opened this issue May 16, 2018 · 4 comments
Closed

[SR-7709] didSet values are incorrect when using KeyPaths #50249

swift-ci opened this issue May 16, 2018 · 4 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-7709
Radar rdar://problem/40308438
Original Reporter xcadaverx (JIRA User)
Type Bug
Status Closed
Resolution Duplicate
Environment

Version 9.3 (9E145) - High Sierra 10.13.4 (17E199)

Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug
Assignee None
Priority Medium

md5: 78d643d1057e0d123bdc650f45823821

duplicates:

  • SR-7695 WritableKeyPath mutation with multiple didSets does not propagate change

relates to:

  • SR-5442 Calling subscript setter with a WritableKeyPath results in wrong invocation order of embedded setters

Issue Description:

Example code courtesy of Vermeulen (JIRA User):

struct Foo {
    var value: Int { didSet {} }
}

struct Bar {
    var foo: Foo { didSet {} }
}

var bar = Bar(foo: Foo(value: 1))

bar.foo[keyPath: \Foo.value] = 2
print(bar.foo.value) // 1

Value is changed to 2, but reading the value reflects '1'.

Removing the didSet causes the printout to be the correct value, 2.

Similar to SR-5442, this also causes the didSet to evaluate its block out of order.

@jckarter
Copy link
Member

@swift-ci create

@swift-ci
Copy link
Collaborator Author

Comment by Daniel Williams (JIRA)

Well shoot, sorry everyone, it looks like Tim already created the bug after our discussion yesterday. I'm going to mark this as a dupe.

Here's his ticket: https://bugs.swift.org/browse/SR-7695

@swift-ci
Copy link
Collaborator Author

Comment by Janusz Bossy (JIRA)

xcadaverx (JIRA User) isn't https://bugs.swift.org/browse/SR-7695 about something completely different? What do KeyPaths have to do with casting?

@swift-ci
Copy link
Collaborator Author

Comment by Janusz Bossy (JIRA)

Sorry, commented on wrong task. Just ignore me.

@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. standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

2 participants