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-296] Fix inconsistencies related to tuples, arg/param lists, type params, typealiases #42918

Closed
jepers opened this issue Dec 18, 2015 · 4 comments
Labels
compiler The Swift compiler in itself task

Comments

@jepers
Copy link

jepers commented Dec 18, 2015

Previous ID SR-296
Radar rdar://23046633
Original Reporter @jepers
Type Task
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Task
Assignee None
Priority Medium

md5: a64b7a283ff1552980ff726c03db02d6

relates to:

  • SR-2216 Confusing behavior related to closure types and tuples

Issue Description:

Demo:

struct Foo<T> {
    let v: T
    init(_ v: T) { self.v = v }
}
typealias Bar = Foo<(Int, Int)>
struct Baz {
    let v: (Int, Int)
    init(_ v: (Int, Int)) { self.v = v }
}
// Study the above and this:
// (I'm not counting argument list parens here):
let f = Foo(1, 2)   // Accepts ZERO OR MORE parens around 1, 2.
let b = Bar(1, 2)   // Accepts ONLY ZERO    parens around 1, 2.
let c = Baz((1, 2)) // Accepts ONE OR MORE  parens around 1, 2.
// You can verify that the rules above are correct by adding and
// removing parens.
// Evidently, Foo<(Int, Int)>, Bar and Baz are different (in that
// their initializers can not be used in the same way).
// But why/how?
@belkadan
Copy link
Contributor

cc cwillmore (JIRA User)

@jepers
Copy link
Author

jepers commented Aug 1, 2016

Here's another related example (same as in the radar):

typealias PairOfInts = (Int, Int)

typealias OptionalPairOfIntsA = Optional<(Int, Int)>
typealias OptionalPairOfIntsB = Optional<PairOfInts>

let p = (1, 2)
let a3 = OptionalPairOfIntsA(p) // OK
let b3 = OptionalPairOfIntsB(p) // OK

let a1 = OptionalPairOfIntsA(1, 2) // OK
let b1 = OptionalPairOfIntsB(1, 2) // Error

let a2 = OptionalPairOfIntsA((1, 2)) // Error
let b2 = OptionalPairOfIntsB((1, 2)) // OK

@slavapestov
Copy link
Member

This has been fixed as part of implemented SE-0110. Please try a Swift 4 development snapshot and put it into Swift 4 mode.

@jepers
Copy link
Author

jepers commented Jun 3, 2017

Please see
https://bugs.swift.org/browse/SR-2216?focusedCommentId=25409&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-25409
for remaining inconsistencies in Swift 4 (latest dev snapshot).

Should I close this issue (because remaining inconsistencies are sufficiently/better reported elsewhere)?

@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
compiler The Swift compiler in itself task
Projects
None yet
Development

No branches or pull requests

3 participants