mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The issue is that the shorthand if let syntax injects an implicit expression: https://github.com/apple/swift/pull/40694/ in ParseStmt and that the 'diagnoseUnhandledAsyncSite' explicitly avoids reporting errors in implicit expressions. This change is that we don't mark the implicit declref code emitted by the `if let prop` as implicit anymore, and this way the reporting works out as expected. Added some tests covering this as well as properly erroring out for the nonexistent syntax of shortand + awaiting which doesn't exist, and we properly error on it. Resolves rdar://126169564
26 lines
1.1 KiB
Swift
26 lines
1.1 KiB
Swift
// RUN: %target-swift-frontend -g -emit-sil %s -parse-as-library -module-name a | %FileCheck %s
|
|
public class C {}
|
|
public enum MyError : Error {
|
|
init() { self.init() }
|
|
}
|
|
public class S {
|
|
private var c = [Int : C?]()
|
|
public func f(_ i: Int) throws -> C {
|
|
guard let x = c[i], let x else {
|
|
// CHECK: sil_scope [[P:[0-9]+]] { loc "{{.*}}":9:5
|
|
// CHECK: sil_scope [[X1_RHS:[0-9]+]] { loc "{{.*}}":9:19 parent [[P]]
|
|
// CHECK: sil_scope [[X1:[0-9]+]] { loc "{{.*}}":9:19 parent [[P]]
|
|
// CHECK: sil_scope [[X2:[0-9]+]] { loc "{{.*}}":9:29 parent [[X1]]
|
|
// CHECK: sil_scope [[X3:[0-9]+]] { loc "{{.*}}":9:29 parent [[X1]]
|
|
// CHECK: sil_scope [[GUARD:[0-9]+]] { loc "{{.*}}":9:36 parent [[P]]
|
|
// CHECK: debug_value {{.*}} : $Optional<C>, let, name "x", {{.*}}, scope [[X1]]
|
|
// CHECK: debug_value {{.*}} : $C, let, name "x", {{.*}}, scope [[X3]]
|
|
// FIXME: This source location is a little wild.
|
|
// CHECK-NEXT: release_value{{.*}}:[[@LINE+5]]:3, scope [[X3]]
|
|
throw MyError()
|
|
// CHECK: function_ref {{.*}}MyError{{.*}}:[[@LINE-1]]:13, scope [[GUARD]]
|
|
}
|
|
return x
|
|
}
|
|
}
|