Moreover, rethrows
is always compiled down to throws(any Error)
. rethrows
is an API thing, not ABI.
func test(_ a: [Int]) -> [Int] {
a.map { $0 }
}
will be (attention to try_apply
and bb2
)
sil hidden @$s6output4testySaySiGACF : $@convention(thin) (@guaranteed Array<Int>) -> @owned Array<Int> {
bb0(%0 : $Array<Int>):
debug_value %0 : $Array<Int>, let, name "a", argno 1, loc "/app/example.swift":1:13, scope 2 // id: %1
%2 = alloc_stack $Array<Int>, loc "/app/example.swift":2:3, scope 2 // users: %7, %3, %9
store %0 to %2 : $*Array<Int>, loc "/app/example.swift":2:3, scope 2 // id: %3
%4 = function_ref @$s6output4testySaySiGACFS2iXEfU_ : $@convention(thin) @substituted <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0) -> (@out τ_0_1, @error any Error) for <Int, Int>, loc * "/app/example.swift":2:9, scope 2 // user: %5
%5 = thin_to_thick_function %4 : $@convention(thin) @substituted <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0) -> (@out τ_0_1, @error any Error) for <Int, Int> to $@noescape @callee_guaranteed @substituted <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0) -> (@out τ_0_1, @error any Error) for <Int, Int>, loc "/app/example.swift":2:9, scope 2 // user: %7
%6 = function_ref @$sSlsE3mapySayqd__Gqd__7ElementQzKXEKlF : $@convention(method) <τ_0_0 where τ_0_0 : Collection><τ_1_0> (@guaranteed @noescape @callee_guaranteed @substituted <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0) -> (@out τ_0_1, @error any Error) for <τ_0_0.Element, τ_1_0>, @in_guaranteed τ_0_0) -> (@owned Array<τ_1_0>, @error any Error), loc "/app/example.swift":2:5, scope 2 // user: %7
try_apply %6<[Int], Int>(%5, %2) : $@convention(method) <τ_0_0 where τ_0_0 : Collection><τ_1_0> (@guaranteed @noescape @callee_guaranteed @substituted <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0) -> (@out τ_0_1, @error any Error) for <τ_0_0.Element, τ_1_0>, @in_guaranteed τ_0_0) -> (@owned Array<τ_1_0>, @error any Error), normal bb1, error bb2, loc "/app/example.swift":2:5, scope 2 // id: %7
bb1(%8 : $Array<Int>): // Preds: bb0
dealloc_stack %2 : $*Array<Int>, loc "/app/example.swift":2:14, scope 2 // id: %9
return %8 : $Array<Int>, loc "/app/example.swift":3:1, scope 2 // id: %10
bb2(%11 : $any Error): // Preds: bb0
unreachable , loc "/app/example.swift":2:5, scope 2 // id: %12
} // end sil function '$s6output4testySaySiGACF'