Skip to content

Commit 1f26028

Browse files
authored
Merge pull request #8366 from brentdax/di-diagnosis-crash
[SIL][DI] Don’t crash when emitting closure errors
2 parents 143b4cf + c6f62b1 commit 1f26028

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ void LifetimeChecker::handleInOutUse(const DIMemoryUse &Use) {
10811081
FD = dyn_cast<FuncDecl>(DSCE->getCalledValue());
10821082
else
10831083
// Operators and normal function calls are just (CallExpr DRE)
1084-
FD = dyn_cast<FuncDecl>(CE->getCalledValue());
1084+
FD = dyn_cast_or_null<FuncDecl>(CE->getCalledValue());
10851085
}
10861086
}
10871087
}

test/SILOptimizer/definite_init_diagnostics.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ func test1() -> Int {
1414
}
1515

1616
func takes_inout(_ a: inout Int) {}
17+
func takes_inout_any(_ a: inout Any) {}
1718
func takes_closure(_ fn: () -> ()) {}
1819

1920
class SomeClass {
@@ -81,6 +82,10 @@ func test2() {
8182
markUsed(b4!)
8283
}
8384
b4 = 7
85+
86+
let b5: Any
87+
b5 = "x"
88+
({ takes_inout_any(&b5) })() // expected-error {{immutable value 'b5' may not be passed inout}}
8489

8590
// Structs
8691
var s1 : SomeStruct

0 commit comments

Comments
 (0)