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-7358] Surprising inconsistency between optional conversion and array conversion #49906

Closed
huonw mannequin opened this issue Apr 5, 2018 · 1 comment
Closed

[SR-7358] Surprising inconsistency between optional conversion and array conversion #49906

huonw mannequin opened this issue Apr 5, 2018 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@huonw
Copy link
Mannequin

huonw mannequin commented Apr 5, 2018

Previous ID SR-7358
Radar None
Original Reporter @huonw
Type Bug
Status Closed
Resolution Duplicate
Environment

Master circa 2018-04-05

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

md5: d840d7907e95c8b1be87e20fd283ac10

is duplicated by:

  • SR-6126 Unexpected casting result in Array/Optional.

Issue Description:

func sameType<T>(_ x: T, _ y: T) {
    print(x, y, T.self)
}

let x = Int?.none
let y = Int??.none
sameType(x, y)

let a: [Int?] = [x]
let b: [Int??] = [y]
sameType(a, b)

This prints

Optional(nil) nil Optional<Optional<Int>>
[nil] [nil] Array<Optional<Optional<Int>>>

That is, the first call both arguments are getting promoted to Int??, and the none in x is getting wrapped in a some to make the Int??, but in the second case, the [Int?] is getting promoted to an [Int??] differently, possibly by (effectively) {{a.map { $0.map { .some($0) } } }}, instead of {{a.map { .some($0) } }} which matches the behaviour of x.

@huonw
Copy link
Mannequin Author

huonw mannequin commented Apr 5, 2018

Misread SR-6126; this is the same problem.

@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

0 participants