@@ -252,6 +252,8 @@ def visit_sequence_pattern(self, o: SequencePattern) -> PatternType:
252252        #    fallback to merging all of their types for each index since we can't handle multiple unpacked items at once yet. 
253253
254254        #  state of matching 
255+         # whether one of the possible types is not handled, in which case we want to return an object 
256+         unknown_value  =  False 
255257        state : (
256258            # Start in the state where we not encountered an unpack. 
257259            # a list of all the possible types that could match the sequence. If it's a tuple, then store one for each index 
@@ -303,6 +305,7 @@ def visit_sequence_pattern(self, o: SequencePattern) -> PatternType:
303305            elif  self .chk .type_is_iterable (t ) and  isinstance (t , Instance ):
304306                inner_t  =  [self .chk .iterable_item_type (t , o )] *  n_patterns 
305307            else :
308+                 unknown_value  =  True 
306309                continue 
307310            # if we previously encountered an unpack, then change the state. 
308311            if  state [0 ] ==  "UNPACK" :
@@ -321,16 +324,19 @@ def visit_sequence_pattern(self, o: SequencePattern) -> PatternType:
321324                union_items [union_index ] =  update_tuple_type 
322325                current_type  =  current_type .copy_modified (items = union_items )
323326            else :
324-                 assert  unpack_index  ==  0 , "Unpack index should be 0 for non-union types" 
327+                 assert  union_index  ==  0 , "Unpack index should be 0 for non-union types" 
325328                current_type  =  update_tuple_type 
326329        else :
327330            unpack_index  =  None 
328-             if  not  state [1 ]:
331+             if  state [1 ]:
332+                 inner_types  =  [
333+                     make_simplified_union (x )
334+                     for  x  in  zip_longest (* state [1 ], fillvalue = UninhabitedType ())
335+                 ]
336+             elif  unknown_value :
337+                 inner_types  =  [self .chk .named_type ("builtins.object" )] *  n_patterns 
338+             else :
329339                return  self .early_non_match ()
330-             inner_types  =  [
331-                 make_simplified_union (x )
332-                 for  x  in  zip_longest (* state [1 ], fillvalue = UninhabitedType ())
333-             ]
334340
335341        # 
336342        # match inner patterns 
0 commit comments