[Parse] Avoid parsing unsafe expression before binary or postfix op (#81429)

rdar://150751248
This commit is contained in:
shiz
2025-05-14 18:02:58 +09:00
committed by GitHub
parent 7ff1066409
commit d12cb84586
2 changed files with 14 additions and 3 deletions

View File

@@ -200,6 +200,8 @@ func unsafeFun() {
_ = color
if unsafe { }
_ = unsafe ? 1 : 0
}
func moreUnsafeFunc(unsafe: [Int]) {
@@ -218,6 +220,13 @@ func yetMoreUnsafeFunc(unsafe: () -> Void) {
// expected-warning@-1{{no unsafe operations occur within 'unsafe' expression}}
}
func yetMoreMoreUnsafeFunc(unsafe: Int?) {
_ = unsafe!
if let unsafe {
_ = unsafe + 1
}
}
// @safe suppresses unsafe-type-related diagnostics on an entity
struct MyArray<Element> {
@safe func withUnsafeBufferPointer<R, E>(