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-5285] Weak reference incorrectly nil'd in Xcode 9 beta 2 (fine in Xcode 9 beta 1) #47860

Closed
swift-ci opened this issue Jun 22, 2017 · 5 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 4.0

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-5285
Radar rdar://problem/32949480
Original Reporter mjholgate (JIRA User)
Type Bug
Status Closed
Resolution Done

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 4.0Regression
Assignee None
Priority Medium

md5: 09921669f917851418125cefcbd7e986

Issue Description:

The following code in Swift, seems to incorrectly clear a weak reference in Xcode 9b2:

//: Playground - noun: a place where people can play

class Foo {

    func iterateArray() {
        ["Abc"].forEach { [weak self] in
            print("self = \(String(describing: self)), $0 = \($0)")
            assert(self != nil)
        }
    }
}

let f = Foo()
f.iterateArray()

Output is:

self = nil, $0 = Abc
assertion failed: file MyPlayground.playground, line 8

This works correctly in Xcode 9 beta 1:

self = Optional(__lldb_expr_1.Foo), $0 = Abc

A playground is attached.

@belkadan
Copy link
Contributor

I'm not reproducing this with master on the command line, but it could be something specific to playgrounds. Thanks for the report.

@belkadan
Copy link
Contributor

@swift-ci create

@swift-ci
Copy link
Collaborator Author

Comment by Matt Holgate (JIRA)

Thanks Jordan!

FWIW, I saw it first in a unit test running from the IDE, then reproduced it in a playground.

@gparker42
Copy link
Mannequin

gparker42 mannequin commented Jun 30, 2017

Reproduced with beta 2 but not with TOT. Might already be fixed.

@gparker42
Copy link
Mannequin

gparker42 mannequin commented Jul 10, 2017

This should be fixed in Xcode 9 beta 3. Thanks for the bug report.

@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 in itself regression swift 4.0
Projects
None yet
Development

No branches or pull requests

3 participants