File tree Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -323,7 +323,7 @@ void StmtEmitter::visitBraceStmt(BraceStmt *S) {
323
323
324
324
// PatternBindingBecls represent local variable bindings that execute
325
325
// as part of the function's execution.
326
- if (!isa<PatternBindingDecl>(D)) {
326
+ if (!isa<PatternBindingDecl>(D) && !isa<VarDecl>(D) ) {
327
327
// Other decls define entities that may be used by the program, such as
328
328
// local function declarations. So handle them here, before checking for
329
329
// reachability, and then continue looping.
@@ -429,12 +429,9 @@ void StmtEmitter::visitBraceStmt(BraceStmt *S) {
429
429
SGF.emitIgnoredExpr (E);
430
430
} else {
431
431
auto *D = ESD.get <Decl*>();
432
-
433
- // Only PatternBindingDecls should be emitted here.
434
- // Other decls were handled above.
435
- auto PBD = cast<PatternBindingDecl>(D);
436
-
437
- SGF.visit (PBD);
432
+ assert ((isa<PatternBindingDecl>(D) || isa<VarDecl>(D)) &&
433
+ " other decls should be handled before the reachability check" );
434
+ SGF.visit (D);
438
435
}
439
436
}
440
437
}
Original file line number Diff line number Diff line change @@ -13,4 +13,6 @@ func foo() {
13
13
// CHECK-LABEL: sil {{.*}} @{{.*}}3foo{{.*}}3bar{{.*}}F : {{.*}} {
14
14
func bar( _: Any ) { }
15
15
16
+ // Check that we don't crash here
17
+ lazy var v = 42
16
18
}
You can’t perform that action at this time.
0 commit comments