Open rvsrvs opened 10 months ago
When run in a playground, the following, related, code fails to compile as well:
struct Ref<T>: ~Copyable {
var value: T
}
func consumingMap<A>(
_ f: @escaping (inout A) -> Void
) -> (consuming Ref<A>) -> Ref<A> {
{ (ref: consuming Ref<A>) -> Ref<A> in
f(&ref.value)
return ref
}
}
with the message: error: couldn't IRGen expression. Please enable the expression log by running "log enable lldb expr", then run the failing expression again, and file a bug report with the log output.
Description
The following code fails to compile with the error message:
ref is borrowed and cannot be consumed.
The following, however, does compile:
Steps to reproduce
Put the above code in a playground. Observe that it does not compile.
Expected behavior
The first code should compile without having to put the explicit type information on the returned closure.
Environment
swift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5) Target: arm64-apple-macosx14.0
Xcode 15.1 Build version 15C5059c
macOS 14