mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Missed this in my previous patch, avoid relying on the `in` location for closures with parameters and capture lists. Instead, form scopes that start at the first element of the body. This fixes a crasher uncovered by the fuzzer.
23 lines
1.0 KiB
Swift
23 lines
1.0 KiB
Swift
// RUN: %target-swift-frontend -g -Xllvm -sil-print-types -emit-sil %s -parse-as-library -module-name a | %FileCheck %s
|
|
// RUN: %target-swift-frontend -g -Xllvm -sil-print-types -emit-sil %s -parse-as-library -module-name a -enable-upcoming-feature ImmutableWeakCaptures | %FileCheck %s --check-prefixes=CHECK,CHECK-HAS-WEAK-LET
|
|
// REQUIRES: swift_feature_ImmutableWeakCaptures
|
|
open class C {
|
|
public func run() {
|
|
{ [weak self] in
|
|
guard let self else { fatalError("cannot happen") }
|
|
// CHECK: sil_scope [[LAMBDA:[0-9]+]] { loc "{{.*}}":6:5
|
|
// CHECK: sil_scope [[LET:[0-9]+]] { loc "{{.*}}":7:7 parent [[LAMBDA]]
|
|
// CHECK-HAS-WEAK-LET: sil_scope [[TMP:[0-9]+]] { loc "{{.*}}":7:17 parent [[LET]]
|
|
// CHECK: sil_scope [[GUARD:[0-9]+]] { loc "{{.*}}":7:17 parent [[LET]]
|
|
// CHECK: debug_value {{.*}} : $C, let, name "self", {{.*}}, scope [[GUARD]]
|
|
// CHECK: function_ref {{.*}}3fun{{.*}}, scope [[GUARD]]
|
|
// CHECK-NEXT: apply {{.*}}, scope [[GUARD]]
|
|
self.fun()
|
|
}()
|
|
}
|
|
public func fun() {}
|
|
}
|
|
|
|
|
|
|