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-1334] function decl. vs closure decl. (not bugs?) #43942

Open
swift-ci opened this issue Apr 27, 2016 · 1 comment
Open

[SR-1334] function decl. vs closure decl. (not bugs?) #43942

swift-ci opened this issue Apr 27, 2016 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-1334
Radar None
Original Reporter VladimirS (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee None
Priority Medium

md5: e9e08c67a6041aa28a44745bd5d0ebfc

Issue Description:

I wanted to ask if founded by me strange behaviour of compiler/parser is bug or it is 'feature' and 'by design' :
(Swift version 3.0-dev (LLVM b010debd0e, Clang 3e4d01d89b, Swift 7182c58))
(IBM Swift Sandbox)

1. I was not expecting this will compile :

let ft1 : (Int,Int) -> Void = { x in print(x.0, x.1)}
ft1(1, 2)

the type of ft1 is definitely not the same as closure

2. The same. But this generates error in runtime :

let ft2 : (Int,Int) -> Void = { x in print(x)}
ft2(1, 2)

3. Could you describe why this compile, as types of closures are not the same

func z1(block: (Int,Int) -> Void) {
    block(1,2)
}

z1 { x, y in print(x,y)}
z1 { x in print(x.0, x.1)}
z1 { (x, y) in print(x, y)}

func z2(block: ((Int,Int)) -> Void) {
    block((1,2))
}

z2 { x, y in print(x,y)}
z2 { x in print(x.0, x.1)}
z2 { (x, y) in print(x, y)}
//z2 { ((x, y)) in print(x, y)}  // compilation error ???

Thank you for your description and comments.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Sep 1, 2016

Comment by Vladimir (JIRA)

Waiting for SE-0110

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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