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-13113] assignment to enum instance should recursively deinitialize associated values #55559

Closed
tayloraswift opened this issue Jun 29, 2020 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@tayloraswift
Copy link
Contributor

Previous ID SR-13113
Radar None
Original Reporter @Kelvin13
Type Bug
Status Resolved
Resolution Duplicate
Environment

$ swift --version
Swift version 5.2-dev (LLVM 4cd92ac, Swift 79716ef)
Target: x86_64-unknown-linux-gnu

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

md5: 678a4cbbc94b90e21d3fced8a6e5ffaa

duplicates:

  • SR-13114 switch statement over enum instance should release references in associated values on successful pattern match

Issue Description:

Right now, the following test program prints `false` when it should print `true`. it works as expected if the `struct` wrapper is removed and the program is compiled with `-O`.

related discussion: https://forums.swift.org/t/why-isn-t-isuniquelyreferenced-working-here/37949/6?u=taylorswift

final
class C 
{
    init() 
    {
    }
}
struct S
{
    var c:C

    init()
    {
        self.c = .init()
    }
    mutating 
    func foo()
    {
        print(isKnownUniquelyReferenced(&self.c))
    }
}

enum E
{
    case empty 
    case s(S) 
}

func foo()  
{
    var e:E = .s(.init())
    switch e 
    {
    case .s(var s):
        e = .empty
        s.foo()
    default:
        break
    }
}

foo()
@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.
Projects
None yet
Development

No branches or pull requests

1 participant