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-2216] Confusing behavior related to closure types and tuples #44823
Comments
Yep, we are part-way through fixing tuples and closures. cc @DougGregor |
Great! Can you say whether or not this will still compile after the fix:
? |
Um. What syntax is that? |
Well, the thing is that it's valid Swift (both 2.2 and 3). |
Ah. I'm not sure where we settled in terms of implicit conversions, but my guess is no change, since this only involves single-element-tuple-to-scalar conversions. |
I thought there where no single-element tuples in Swift? |
So did I, but that's the only explanation I have. |
|
A casual interpretation of the current behavior/design is: "I can wrap almost any expression in parenthesis and label it, sort of like comments." Like for example: let (me: (declare: (the: (constant: result)))) = (one: 1) + (two: 2)
_ = (now_let_me: print((the_result: (namely_the_constant: result))))
// Prints 3 I get a feeling that it will take quite some time before all of this is sorted out. Perhaps the design (of parenthesized expressions, tuples, closure types, etc) needs to be reexamined/reevaluated from scratch? Newcomers and experienced programmers alike are probably surprised and confused by trying to make sense of simple things like:
|
This was fixed as part of implementing SE-0110 in Swift 4. Please try a recent Swift 4 snapshot. |
Some of the inconsistencies have been fixed, but definitely not all, as the following demonstrates.
|
Should I close this (broad) issue and file a new one that is more specifically about the remaining inconsistencies (demonstrated in my above comment)? Or perhaps those inconsistencies are already sufficiently identified/reported? |
The remaining inconsistency is that the runtime type system still does not distinguish tuples from argument lists. The "let add_b: B = ➕" bit is a bug unfortunately, it should not have been accepted. |
Ok, thanks. Also, the following will not compile (dev snapshot 2017-06-02, Swift 4):
I would expect it to compile since they take different function types. To me, this doesn't look like it has anything to do with the runtime type system, so it is another bug? Are all bugs like these sufficiently reported or should I file new ones? |
Environment
Xcode 8 beta 3, OS X 10.11.6
Additional Detail from JIRA
md5: 462fe2809af80eb2c928975f227a8b51
relates to:
Issue Description:
Shortest example:
More detailed example:
And one more example:
The text was updated successfully, but these errors were encountered: