Skip to content

Instantly share code, notes, and snippets.

@maxcan
Created September 20, 2014 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxcan/e2ccadcc2e3a78fd0b9e to your computer and use it in GitHub Desktop.
Save maxcan/e2ccadcc2e3a78fd0b9e to your computer and use it in GitHub Desktop.
type inference failing on closures
// this compiles:
private func loadMessages() {
getMsgList(self.auth).map() { (listRes:Result<MsgList>) -> Void in
switch(listRes) {
case let .Value(v):
die("swift needs type holes",43)
case let .Error(e): die("ERROR getting msgres: \(e)", 6)
}
return
}
}
// This fails with:
// Cannot convert the expression's type '(($T8) -> ($T8) -> $T7) -> (($T8) -> $T7) -> $T7' to type 'B'
private func loadMessages() {
getMsgList(self.auth).map() {
switch($0) {
case let .Value(v):
die("swift needs type holes",43)
case let .Error(e): die("ERROR getting msgres: \(e)", 6)
}
return
}
}
// same failure as above
private func loadMessages() {
getMsgList(self.auth).map() { a in
switch(a) {
case let .Value(v):
die("swift needs type holes",43)
case let .Error(e): die("ERROR getting msgres: \(e)", 6)
}
return
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment