@@ -1866,16 +1866,18 @@ def type_check_raise(self, e: Node, s: RaiseStmt) -> None:
18661866
18671867 def visit_try_stmt (self , s : TryStmt ) -> Type :
18681868 """Type check a try statement."""
1869+ broken = True
18691870 with self .binder .frame_context ():
1870- with self .binder .frame_context (fall_through = True , clear_breaking = True ):
1871+ with self .binder .frame_context (fall_through = True , clear_breaking = True ) as frame :
18711872 self .binder .try_frames .add (len (self .binder .frames ) - 2 )
18721873 self .accept (s .body )
18731874 self .binder .try_frames .remove (len (self .binder .frames ) - 2 )
18741875 if s .else_body :
18751876 self .accept (s .else_body )
1877+ broken = broken and frame .broken
18761878
18771879 for i in range (len (s .handlers )):
1878- with self .binder .frame_context (clear_breaking = True ):
1880+ with self .binder .frame_context (clear_breaking = True ) as frame :
18791881 if s .types [i ]:
18801882 t = self .visit_except_handler_test (s .types [i ])
18811883 if s .vars [i ]:
@@ -1899,9 +1901,12 @@ def visit_try_stmt(self, s: TryStmt) -> Type:
18991901 var = cast (Var , s .vars [i ].node )
19001902 var .type = DeletedType (source = source )
19011903 self .binder .cleanse (s .vars [i ])
1904+ broken = broken and frame .broken
19021905
19031906 if s .finally_body :
19041907 self .accept (s .finally_body )
1908+ if broken :
1909+ self .binder .breaking_out = True
19051910
19061911 def visit_except_handler_test (self , n : Node ) -> Type :
19071912 """Type check an exception handler test clause."""
0 commit comments