Closed
Description
Previous ID | SR-3417 |
Radar | None |
Original Reporter | hughbe (JIRA User) |
Type | Bug |
Status | Resolved |
Resolution | Done |
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Bug, Parser, TypeChecker |
Assignee | maustinstar (JIRA) |
Priority | Medium |
md5: 9e8c4f62db5afe1e6df957fc5c116a33
Issue Description:
The following code feels like it should work, but doesn't
public func _stdlib_pipe() -> (readEnd: CInt, writeEnd: CInt, error: CInt) {
var fds: [CInt] = [0, 0]
let ret = fds.withUnsafeMutableBufferPointer { unsafeFds -> CInt in
#if !os(Windows) || CYGWIN
pipe(unsafeFds.baseAddress)
#else
_pipe(unsafeFds.baseAddress, 0, 0)
#endif
}
return (readEnd: fds[0], writeEnd: fds[1], error: ret)
}
Instead, you need to include an explicit return as the closure can no longer be a single expression closure.
public func _stdlib_pipe() -> (readEnd: CInt, writeEnd: CInt, error: CInt) {
var fds: [CInt] = [0, 0]
let ret = fds.withUnsafeMutableBufferPointer { unsafeFds -> CInt in
#if !os(Windows) || CYGWIN
return pipe(unsafeFds.baseAddress)
#else
return _pipe(unsafeFds.baseAddress, 0, 0)
#endif
}
return (readEnd: fds[0], writeEnd: fds[1], error: ret)
}