2525from mypy .constraints import SUPERTYPE_OF
2626from mypy .erasetype import erase_type , erase_typevars , remove_instance_last_known_values
2727from mypy .errorcodes import TYPE_VAR , UNUSED_AWAITABLE , UNUSED_COROUTINE , ErrorCode
28- from mypy .errors import Errors , ErrorWatcher , LoopErrorWatcher , report_internal_error
28+ from mypy .errors import ErrorInfo , Errors , ErrorWatcher , LoopErrorWatcher , report_internal_error
2929from mypy .expandtype import expand_type
3030from mypy .literals import Key , extract_var_from_literal_hash , literal , literal_hash
3131from mypy .maptype import map_instance_to_supertype
@@ -3840,7 +3840,7 @@ def check_assignment_to_multiple_lvalues(
38403840 if rvalue_needed > 0 :
38413841 rvalues = (
38423842 rvalues [0 :iterable_start ]
3843- + [TempNode (iterable_type ) for i in range (rvalue_needed )]
3843+ + [TempNode (iterable_type , context = rval ) for _ in range (rvalue_needed )]
38443844 + rvalues [iterable_end + 1 :]
38453845 )
38463846
@@ -7181,7 +7181,7 @@ def check_subtype(
71817181 if extra_info :
71827182 msg = msg .with_additional_msg (" (" + ", " .join (extra_info ) + ")" )
71837183
7184- self .fail (msg , context )
7184+ error = self .fail (msg , context )
71857185 for note in notes :
71867186 self .msg .note (note , context , code = msg .code )
71877187 if note_msg :
@@ -7192,7 +7192,7 @@ def check_subtype(
71927192 and supertype .type .is_protocol
71937193 and isinstance (subtype , (CallableType , Instance , TupleType , TypedDictType , TypeType ))
71947194 ):
7195- self .msg .report_protocol_problems (subtype , supertype , context , code = msg . code )
7195+ self .msg .report_protocol_problems (subtype , supertype , context , parent_error = error )
71967196 if isinstance (supertype , CallableType ) and isinstance (subtype , Instance ):
71977197 call = find_member ("__call__" , subtype , subtype , is_operator = True )
71987198 if call :
@@ -7521,12 +7521,11 @@ def temp_node(self, t: Type, context: Context | None = None) -> TempNode:
75217521
75227522 def fail (
75237523 self , msg : str | ErrorMessage , context : Context , * , code : ErrorCode | None = None
7524- ) -> None :
7524+ ) -> ErrorInfo :
75257525 """Produce an error message."""
75267526 if isinstance (msg , ErrorMessage ):
7527- self .msg .fail (msg .value , context , code = msg .code )
7528- return
7529- self .msg .fail (msg , context , code = code )
7527+ return self .msg .fail (msg .value , context , code = msg .code )
7528+ return self .msg .fail (msg , context , code = code )
75307529
75317530 def note (
75327531 self ,
0 commit comments