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) {
323323
324324 // PatternBindingBecls represent local variable bindings that execute
325325 // as part of the function's execution.
326- if (!isa<PatternBindingDecl>(D)) {
326+ if (!isa<PatternBindingDecl>(D) && !isa<VarDecl>(D) ) {
327327 // Other decls define entities that may be used by the program, such as
328328 // local function declarations. So handle them here, before checking for
329329 // reachability, and then continue looping.
@@ -429,12 +429,9 @@ void StmtEmitter::visitBraceStmt(BraceStmt *S) {
429429 SGF.emitIgnoredExpr (E);
430430 } else {
431431 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);
438435 }
439436 }
440437}
Original file line number Diff line number Diff line change @@ -13,4 +13,6 @@ func foo() {
1313 // CHECK-LABEL: sil {{.*}} @{{.*}}3foo{{.*}}3bar{{.*}}F : {{.*}} {
1414 func bar( _: Any ) { }
1515
16+ // Check that we don't crash here
17+ lazy var v = 42
1618}
You can’t perform that action at this time.
0 commit comments