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.
@@ -428,12 +428,9 @@ void StmtEmitter::visitBraceStmt(BraceStmt *S) {
428428 SGF.emitIgnoredExpr (E);
429429 } else {
430430 auto *D = ESD.get <Decl*>();
431-
432- // Only PatternBindingDecls should be emitted here.
433- // Other decls were handled above.
434- auto PBD = cast<PatternBindingDecl>(D);
435-
436- SGF.visit (PBD);
431+ assert ((isa<PatternBindingDecl>(D) || isa<VarDecl>(D)) &&
432+ " other decls should be handled before the reachability check" );
433+ SGF.visit (D);
437434 }
438435 }
439436}
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