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-10272] Mirror fails to reflect enums that have a single-case enum as their associated values. #52672

Closed
swift-ci opened this issue Apr 2, 2019 · 6 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. runtime The Swift Runtime standard library Area: Standard library umbrella

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Apr 2, 2019

Previous ID SR-10272
Radar None
Original Reporter andersha (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Playground
Swift 4.2, Xcode 10.1
Swift 5.0, Xcode 10.2

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

md5: 596868fcf15743724a3511c32101f02d

Issue Description:

If the inner enum type has more than one case, `Mirror` can reflect without issue.
But if the inner enum type has just one case, `Mirror` returns no children at all.

Code snippet:

enum Inner {
    case hello
//    case no
}

enum Outer {
    case inner(Inner)
}

print(
    Mirror(reflecting: Outer.inner(.hello)).children.map { $0 }
)
// Print `[]` when `Inner` has only `hello`.
// Print `[(label: Optional("inner"), value: __lldb_expr_1.Inner.hello)]` when `Inner` has both `hello` and `no`.
@belkadan
Copy link
Contributor

belkadan commented Apr 3, 2019

@jckarter, @mikeash, I think we have a Radar for this already?

@mikeash
Copy link
Contributor

mikeash commented Apr 3, 2019

Seems like the sort of thing we'd have, but I couldn't find one. Maybe we don't!

@swift-ci
Copy link
Collaborator Author

Comment by James Froggatt (JIRA)

Hi, this appears to be part of a wider issue affecting enums with associated values of zero size. I've created ticket SR-12255 describing the problem.

@swift-ci
Copy link
Collaborator Author

Comment by James Froggatt (JIRA)

Turns out the fix was merged into master a few days ago: #29901

@mikeash
Copy link
Contributor

mikeash commented Feb 24, 2020

Nice, I guess we had a duplicate and didn't make the association. I'll mark this one and SR-12255 as resolved, then.

@mikeash
Copy link
Contributor

mikeash commented Feb 24, 2020

Fixed by #29901

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

No branches or pull requests

3 participants