From 22ca9cca88a839cf4b1ce3b25ce83d4a7bf4a88d Mon Sep 17 00:00:00 2001 From: Katrina Connors Date: Fri, 26 Jul 2024 13:32:55 -0700 Subject: [PATCH 01/14] added error code, message, in prog test --- mypy/checker.py | 1 + mypy/errorcodes.py | 6 ++++++ mypy/message_registry.py | 5 +++++ test-data/unit/check-errorcodes.test | 17 +++++++++++++++++ 4 files changed, 29 insertions(+) diff --git a/mypy/checker.py b/mypy/checker.py index 59de599006a8..0f2743b2394f 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -768,6 +768,7 @@ def check_overlapping_overloads(self, defn: OverloadedFuncDef) -> None: continue if overload_can_never_match(sig1, sig2): + self.msg.overloaded_signature_will_never_match(i + 1, i + j + 2, item2.func) elif not is_descriptor_get: # Note: we force mypy to check overload signatures in strict-optional mode diff --git a/mypy/errorcodes.py b/mypy/errorcodes.py index 6e8763264ddd..35640a89c7e8 100644 --- a/mypy/errorcodes.py +++ b/mypy/errorcodes.py @@ -262,6 +262,12 @@ def __hash__(self) -> int: default_enabled=False, ) +OVERLOADED_FUNCTION_MATCHING: Final[ErrorCode] = ErrorCode( + "overloaded-function-matching", + "Warn user about signature matching for overloaded functions.", + "General", +) + # Syntax errors are often blocking. SYNTAX: Final[ErrorCode] = ErrorCode("syntax", "Report syntax errors", "General") diff --git a/mypy/message_registry.py b/mypy/message_registry.py index 29d539faaed6..d50ac44bbae0 100644 --- a/mypy/message_registry.py +++ b/mypy/message_registry.py @@ -362,3 +362,8 @@ def with_additional_msg(self, info: str) -> ErrorMessage: TYPE_ALIAS_WITH_AWAIT_EXPRESSION: Final = ErrorMessage( "Await expression cannot be used within a type alias", codes.SYNTAX ) + +# Overloads +OVERLOADED_FUNCTION_SIGNATURE: Final = ErrorMessage( + "Overloaded function signature {} will never be matched", codes.OVERLOADED_FUNCTION_MATCHING +) \ No newline at end of file diff --git a/test-data/unit/check-errorcodes.test b/test-data/unit/check-errorcodes.test index c4d72388fba9..75df2270fdac 100644 --- a/test-data/unit/check-errorcodes.test +++ b/test-data/unit/check-errorcodes.test @@ -1196,3 +1196,20 @@ def f(x: str) -> TypeIs[int]: # E: Narrowed type "int" is not a subtype of inpu pass [builtins fixtures/tuple.pyi] + + +[case testOverloadedFunctionSignature] +from typing import overload, Union + +@overload +def process(response1: float,response2: float) -> float: + ... +@overload +def process(response1: int,response2: int) -> int: # E: Overloaded function signature 2 will never be matched: signature 1's parameter type(s) are the same or broader [overloaded-function-matching] + ... + +def process(response1,response2)-> Union[float,int]: + return response1 + response2 + + + From 66bca55983908deffaaebda54506cdb4d4cc03be Mon Sep 17 00:00:00 2001 From: Katrina Connors Date: Fri, 26 Jul 2024 14:37:25 -0700 Subject: [PATCH 02/14] error code,update docs --- docs/source/error_code_list.rst | 17 +++++++++++++++++ mypy/messages.py | 1 + 2 files changed, 18 insertions(+) diff --git a/docs/source/error_code_list.rst b/docs/source/error_code_list.rst index 64d9a1d03287..269cfa8d2f84 100644 --- a/docs/source/error_code_list.rst +++ b/docs/source/error_code_list.rst @@ -1151,6 +1151,23 @@ See :ref:`overloading ` for more explanation. .. _code-annotation-unchecked: +Check error code of overload function signature match +-------------------------------------------------------------------------- + +.. code-block:: python + + from typing import overload, Union + + @overload + def process(response1: float,response2: float) -> float: + ... + @overload + def process(response1: int,response2: int) -> int: # E: Overloaded function signature 2 will never be matched: signature 1's parameter type(s) are the same or broader [overloaded-function-matching] + ... + + def process(response1,response2)-> Union[float,int]: + return response1 + response2 + Notify about an annotation in an unchecked function [annotation-unchecked] -------------------------------------------------------------------------- diff --git a/mypy/messages.py b/mypy/messages.py index 62846c536f3d..ee7fb33056e7 100644 --- a/mypy/messages.py +++ b/mypy/messages.py @@ -1653,6 +1653,7 @@ def overloaded_signature_will_never_match( index1=index1, index2=index2 ), context, + code=codes.OVERLOADED_FUNCTION_MATCHING, ) def overloaded_signatures_typevar_specific(self, index: int, context: Context) -> None: From 85ea18ba46d4ee4934c325b60b111b5ac05d29da Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 26 Jul 2024 21:48:15 +0000 Subject: [PATCH 03/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/source/error_code_list.rst | 2 +- mypy/checker.py | 2 +- mypy/message_registry.py | 2 +- test-data/unit/check-errorcodes.test | 5 +---- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/docs/source/error_code_list.rst b/docs/source/error_code_list.rst index 269cfa8d2f84..9c9be815ad74 100644 --- a/docs/source/error_code_list.rst +++ b/docs/source/error_code_list.rst @@ -1165,7 +1165,7 @@ Check error code of overload function signature match def process(response1: int,response2: int) -> int: # E: Overloaded function signature 2 will never be matched: signature 1's parameter type(s) are the same or broader [overloaded-function-matching] ... - def process(response1,response2)-> Union[float,int]: + def process(response1,response2)-> Union[float,int]: return response1 + response2 Notify about an annotation in an unchecked function [annotation-unchecked] diff --git a/mypy/checker.py b/mypy/checker.py index 0f2743b2394f..c4a6b8a85870 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -768,7 +768,7 @@ def check_overlapping_overloads(self, defn: OverloadedFuncDef) -> None: continue if overload_can_never_match(sig1, sig2): - + self.msg.overloaded_signature_will_never_match(i + 1, i + j + 2, item2.func) elif not is_descriptor_get: # Note: we force mypy to check overload signatures in strict-optional mode diff --git a/mypy/message_registry.py b/mypy/message_registry.py index d50ac44bbae0..f26b0b5b2d91 100644 --- a/mypy/message_registry.py +++ b/mypy/message_registry.py @@ -366,4 +366,4 @@ def with_additional_msg(self, info: str) -> ErrorMessage: # Overloads OVERLOADED_FUNCTION_SIGNATURE: Final = ErrorMessage( "Overloaded function signature {} will never be matched", codes.OVERLOADED_FUNCTION_MATCHING -) \ No newline at end of file +) diff --git a/test-data/unit/check-errorcodes.test b/test-data/unit/check-errorcodes.test index 75df2270fdac..c762dc0a52ef 100644 --- a/test-data/unit/check-errorcodes.test +++ b/test-data/unit/check-errorcodes.test @@ -1208,8 +1208,5 @@ def process(response1: float,response2: float) -> float: def process(response1: int,response2: int) -> int: # E: Overloaded function signature 2 will never be matched: signature 1's parameter type(s) are the same or broader [overloaded-function-matching] ... -def process(response1,response2)-> Union[float,int]: +def process(response1,response2)-> Union[float,int]: return response1 + response2 - - - From 243f3dfb4b0e683c69a9e8239019eebc8e8f135e Mon Sep 17 00:00:00 2001 From: Katrina Connors Date: Fri, 26 Jul 2024 15:01:01 -0700 Subject: [PATCH 04/14] updated docs post check doc build --- docs/source/error_code_list.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/source/error_code_list.rst b/docs/source/error_code_list.rst index 9c9be815ad74..2556f59c132c 100644 --- a/docs/source/error_code_list.rst +++ b/docs/source/error_code_list.rst @@ -1149,7 +1149,8 @@ types you expect. See :ref:`overloading ` for more explanation. -.. _code-annotation-unchecked: + +.. _code-overloaded-function-matching: Check error code of overload function signature match -------------------------------------------------------------------------- @@ -1168,6 +1169,8 @@ Check error code of overload function signature match def process(response1,response2)-> Union[float,int]: return response1 + response2 +.. _code-annotation-unchecked: + Notify about an annotation in an unchecked function [annotation-unchecked] -------------------------------------------------------------------------- From bf1cae566845134fcf5a313bc59696d350c521ec Mon Sep 17 00:00:00 2001 From: Katrina Connors <32425204+katconnors@users.noreply.github.com> Date: Mon, 29 Jul 2024 16:54:19 -0700 Subject: [PATCH 05/14] Update mypy/errorcodes.py Co-authored-by: Alex Waygood --- mypy/errorcodes.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mypy/errorcodes.py b/mypy/errorcodes.py index 35640a89c7e8..ff6582828613 100644 --- a/mypy/errorcodes.py +++ b/mypy/errorcodes.py @@ -266,6 +266,7 @@ def __hash__(self) -> int: "overloaded-function-matching", "Warn user about signature matching for overloaded functions.", "General", + sub_code_of=MISC, ) # Syntax errors are often blocking. From a9c5d57deaf77f18514abae0d95730a694a54d3c Mon Sep 17 00:00:00 2001 From: Katrina Connors Date: Mon, 29 Jul 2024 16:58:56 -0700 Subject: [PATCH 06/14] moving around error code --- mypy/errorcodes.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mypy/errorcodes.py b/mypy/errorcodes.py index ff6582828613..555e240665c5 100644 --- a/mypy/errorcodes.py +++ b/mypy/errorcodes.py @@ -262,12 +262,6 @@ def __hash__(self) -> int: default_enabled=False, ) -OVERLOADED_FUNCTION_MATCHING: Final[ErrorCode] = ErrorCode( - "overloaded-function-matching", - "Warn user about signature matching for overloaded functions.", - "General", - sub_code_of=MISC, -) # Syntax errors are often blocking. SYNTAX: Final[ErrorCode] = ErrorCode("syntax", "Report syntax errors", "General") @@ -280,6 +274,14 @@ def __hash__(self) -> int: # This is a catch-all for remaining uncategorized errors. MISC: Final[ErrorCode] = ErrorCode("misc", "Miscellaneous other checks", "General") +OVERLOADED_FUNCTION_MATCHING: Final[ErrorCode] = ErrorCode( + "overloaded-function-matching", + "Warn user about signature matching for overloaded functions.", + "General", + sub_code_of=MISC, +) + + OVERLOAD_OVERLAP: Final[ErrorCode] = ErrorCode( "overload-overlap", "Warn if multiple @overload variants overlap in unsafe ways", From e28d3a43c5ec83faf27c30bf51274bdf80d215c3 Mon Sep 17 00:00:00 2001 From: Katrina Connors Date: Mon, 29 Jul 2024 21:52:35 -0700 Subject: [PATCH 07/14] error rename --- docs/source/error_code_list.rst | 4 ++-- mypy/checker.py | 1 - mypy/errorcodes.py | 5 ++--- mypy/message_registry.py | 2 +- mypy/messages.py | 2 +- test-data/unit/check-errorcodes.test | 2 +- 6 files changed, 7 insertions(+), 9 deletions(-) diff --git a/docs/source/error_code_list.rst b/docs/source/error_code_list.rst index 2556f59c132c..29176f3224c7 100644 --- a/docs/source/error_code_list.rst +++ b/docs/source/error_code_list.rst @@ -1150,7 +1150,7 @@ types you expect. See :ref:`overloading ` for more explanation. -.. _code-overloaded-function-matching: +.. _code-overload-cannot-match: Check error code of overload function signature match -------------------------------------------------------------------------- @@ -1163,7 +1163,7 @@ Check error code of overload function signature match def process(response1: float,response2: float) -> float: ... @overload - def process(response1: int,response2: int) -> int: # E: Overloaded function signature 2 will never be matched: signature 1's parameter type(s) are the same or broader [overloaded-function-matching] + def process(response1: int,response2: int) -> int: # E: Overloaded function signature 2 will never be matched: signature 1's parameter type(s) are the same or broader [overload-cannot-match] ... def process(response1,response2)-> Union[float,int]: diff --git a/mypy/checker.py b/mypy/checker.py index c4a6b8a85870..59de599006a8 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -768,7 +768,6 @@ def check_overlapping_overloads(self, defn: OverloadedFuncDef) -> None: continue if overload_can_never_match(sig1, sig2): - self.msg.overloaded_signature_will_never_match(i + 1, i + j + 2, item2.func) elif not is_descriptor_get: # Note: we force mypy to check overload signatures in strict-optional mode diff --git a/mypy/errorcodes.py b/mypy/errorcodes.py index 555e240665c5..9f7b340f43f0 100644 --- a/mypy/errorcodes.py +++ b/mypy/errorcodes.py @@ -262,7 +262,6 @@ def __hash__(self) -> int: default_enabled=False, ) - # Syntax errors are often blocking. SYNTAX: Final[ErrorCode] = ErrorCode("syntax", "Report syntax errors", "General") @@ -274,8 +273,8 @@ def __hash__(self) -> int: # This is a catch-all for remaining uncategorized errors. MISC: Final[ErrorCode] = ErrorCode("misc", "Miscellaneous other checks", "General") -OVERLOADED_FUNCTION_MATCHING: Final[ErrorCode] = ErrorCode( - "overloaded-function-matching", +OVERLOAD_CANNOT_MATCH: Final[ErrorCode] = ErrorCode( + "overload-cannot-match", "Warn user about signature matching for overloaded functions.", "General", sub_code_of=MISC, diff --git a/mypy/message_registry.py b/mypy/message_registry.py index f26b0b5b2d91..a3e087296ee9 100644 --- a/mypy/message_registry.py +++ b/mypy/message_registry.py @@ -365,5 +365,5 @@ def with_additional_msg(self, info: str) -> ErrorMessage: # Overloads OVERLOADED_FUNCTION_SIGNATURE: Final = ErrorMessage( - "Overloaded function signature {} will never be matched", codes.OVERLOADED_FUNCTION_MATCHING + "Overloaded function signature {} will never be matched", codes.OVERLOAD_CANNOT_MATCH ) diff --git a/mypy/messages.py b/mypy/messages.py index ee7fb33056e7..dadce149680e 100644 --- a/mypy/messages.py +++ b/mypy/messages.py @@ -1653,7 +1653,7 @@ def overloaded_signature_will_never_match( index1=index1, index2=index2 ), context, - code=codes.OVERLOADED_FUNCTION_MATCHING, + code=codes.OVERLOAD_CANNOT_MATCH, ) def overloaded_signatures_typevar_specific(self, index: int, context: Context) -> None: diff --git a/test-data/unit/check-errorcodes.test b/test-data/unit/check-errorcodes.test index c762dc0a52ef..08cf01d2189e 100644 --- a/test-data/unit/check-errorcodes.test +++ b/test-data/unit/check-errorcodes.test @@ -1205,7 +1205,7 @@ from typing import overload, Union def process(response1: float,response2: float) -> float: ... @overload -def process(response1: int,response2: int) -> int: # E: Overloaded function signature 2 will never be matched: signature 1's parameter type(s) are the same or broader [overloaded-function-matching] +def process(response1: int,response2: int) -> int: # E: Overloaded function signature 2 will never be matched: signature 1's parameter type(s) are the same or broader [overload-cannot-match] ... def process(response1,response2)-> Union[float,int]: From 81857838f7f3649a53d0eac9f4dcd72576416989 Mon Sep 17 00:00:00 2001 From: Katrina Connors Date: Mon, 29 Jul 2024 22:02:49 -0700 Subject: [PATCH 08/14] doc improvements --- docs/source/error_code_list.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/source/error_code_list.rst b/docs/source/error_code_list.rst index 29176f3224c7..4c4d86670595 100644 --- a/docs/source/error_code_list.rst +++ b/docs/source/error_code_list.rst @@ -1155,6 +1155,12 @@ See :ref:`overloading ` for more explanation. Check error code of overload function signature match -------------------------------------------------------------------------- +In the case of an overloaded function, if one of the signatures is never accessible, this error may occur. +An example where this can occur is with the utilization of floats and int types, due to the behavior of integers matching floats in mypy. +Consider swapping the declaration of the two types so that the narrower signature is declared before the broader signature. + +Example: + .. code-block:: python from typing import overload, Union From d842385b413b5dd37e480d7c17b2d4bedd5c7d68 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 30 Jul 2024 05:03:38 +0000 Subject: [PATCH 09/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/source/error_code_list.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/error_code_list.rst b/docs/source/error_code_list.rst index 4c4d86670595..31c2a27f8954 100644 --- a/docs/source/error_code_list.rst +++ b/docs/source/error_code_list.rst @@ -1157,7 +1157,7 @@ Check error code of overload function signature match In the case of an overloaded function, if one of the signatures is never accessible, this error may occur. An example where this can occur is with the utilization of floats and int types, due to the behavior of integers matching floats in mypy. -Consider swapping the declaration of the two types so that the narrower signature is declared before the broader signature. +Consider swapping the declaration of the two types so that the narrower signature is declared before the broader signature. Example: From 795bae5ebdd8134ddd1a03ac14d741b6be55edb9 Mon Sep 17 00:00:00 2001 From: Katrina Connors Date: Tue, 13 Aug 2024 20:16:02 -0700 Subject: [PATCH 10/14] consistent formatting for docs and error codes --- docs/source/error_code_list.rst | 2 +- mypy/errorcodes.py | 2 +- mypy/message_registry.py | 5 ----- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/docs/source/error_code_list.rst b/docs/source/error_code_list.rst index 31c2a27f8954..690a04ee382f 100644 --- a/docs/source/error_code_list.rst +++ b/docs/source/error_code_list.rst @@ -1152,7 +1152,7 @@ See :ref:`overloading ` for more explanation. .. _code-overload-cannot-match: -Check error code of overload function signature match +Check for overload signatures that cannot match [overload-cannot-match] -------------------------------------------------------------------------- In the case of an overloaded function, if one of the signatures is never accessible, this error may occur. diff --git a/mypy/errorcodes.py b/mypy/errorcodes.py index 9f7b340f43f0..ad061b161af1 100644 --- a/mypy/errorcodes.py +++ b/mypy/errorcodes.py @@ -275,7 +275,7 @@ def __hash__(self) -> int: OVERLOAD_CANNOT_MATCH: Final[ErrorCode] = ErrorCode( "overload-cannot-match", - "Warn user about signature matching for overloaded functions.", + "Warn if an @overload signature can never be matched", "General", sub_code_of=MISC, ) diff --git a/mypy/message_registry.py b/mypy/message_registry.py index a3e087296ee9..29d539faaed6 100644 --- a/mypy/message_registry.py +++ b/mypy/message_registry.py @@ -362,8 +362,3 @@ def with_additional_msg(self, info: str) -> ErrorMessage: TYPE_ALIAS_WITH_AWAIT_EXPRESSION: Final = ErrorMessage( "Await expression cannot be used within a type alias", codes.SYNTAX ) - -# Overloads -OVERLOADED_FUNCTION_SIGNATURE: Final = ErrorMessage( - "Overloaded function signature {} will never be matched", codes.OVERLOAD_CANNOT_MATCH -) From a511ed6d8c884082c209faa67ae6f165b51cb894 Mon Sep 17 00:00:00 2001 From: Katrina Connors Date: Tue, 13 Aug 2024 20:19:22 -0700 Subject: [PATCH 11/14] changed example --- docs/source/error_code_list.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/error_code_list.rst b/docs/source/error_code_list.rst index 690a04ee382f..324aad93ecae 100644 --- a/docs/source/error_code_list.rst +++ b/docs/source/error_code_list.rst @@ -1156,7 +1156,7 @@ Check for overload signatures that cannot match [overload-cannot-match] -------------------------------------------------------------------------- In the case of an overloaded function, if one of the signatures is never accessible, this error may occur. -An example where this can occur is with the utilization of floats and int types, due to the behavior of integers matching floats in mypy. +An example where this can occur is with the utilization of object and int types. Consider swapping the declaration of the two types so that the narrower signature is declared before the broader signature. Example: @@ -1166,13 +1166,13 @@ Example: from typing import overload, Union @overload - def process(response1: float,response2: float) -> float: + def process(response1: object,response2: object) -> object: ... @overload def process(response1: int,response2: int) -> int: # E: Overloaded function signature 2 will never be matched: signature 1's parameter type(s) are the same or broader [overload-cannot-match] ... - def process(response1,response2)-> Union[float,int]: + def process(response1,response2)-> Union[object,int]: return response1 + response2 .. _code-annotation-unchecked: From 5613432cf34d919633b49a2f3c04cadea6a8414b Mon Sep 17 00:00:00 2001 From: Katrina Connors <32425204+katconnors@users.noreply.github.com> Date: Fri, 13 Sep 2024 16:09:14 -0700 Subject: [PATCH 12/14] Update docs/source/error_code_list.rst Co-authored-by: Jelle Zijlstra --- docs/source/error_code_list.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/error_code_list.rst b/docs/source/error_code_list.rst index 324aad93ecae..2842d941f5c5 100644 --- a/docs/source/error_code_list.rst +++ b/docs/source/error_code_list.rst @@ -1173,7 +1173,7 @@ Example: ... def process(response1,response2)-> Union[object,int]: - return response1 + response2 + return response1 + response2 .. _code-annotation-unchecked: From 84ccbabe659b7f61620b881611074ecf7fa13c13 Mon Sep 17 00:00:00 2001 From: Katrina Connors <32425204+katconnors@users.noreply.github.com> Date: Fri, 13 Sep 2024 16:10:24 -0700 Subject: [PATCH 13/14] Update docs/source/error_code_list.rst Co-authored-by: Jelle Zijlstra --- docs/source/error_code_list.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/error_code_list.rst b/docs/source/error_code_list.rst index 2842d941f5c5..f5537073b8bc 100644 --- a/docs/source/error_code_list.rst +++ b/docs/source/error_code_list.rst @@ -1166,13 +1166,13 @@ Example: from typing import overload, Union @overload - def process(response1: object,response2: object) -> object: + def process(response1: object, response2: object) -> object: ... @overload - def process(response1: int,response2: int) -> int: # E: Overloaded function signature 2 will never be matched: signature 1's parameter type(s) are the same or broader [overload-cannot-match] + def process(response1: int, response2: int) -> int: # E: Overloaded function signature 2 will never be matched: signature 1's parameter type(s) are the same or broader [overload-cannot-match] ... - def process(response1,response2)-> Union[object,int]: + def process(response1: object, response2: object) -> object: return response1 + response2 .. _code-annotation-unchecked: From 4f9c68a060cff9a72b576913eaa4ed55c70329a9 Mon Sep 17 00:00:00 2001 From: Katrina Connors <32425204+katconnors@users.noreply.github.com> Date: Fri, 13 Sep 2024 16:11:01 -0700 Subject: [PATCH 14/14] Update docs/source/error_code_list.rst Co-authored-by: Jelle Zijlstra --- docs/source/error_code_list.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/source/error_code_list.rst b/docs/source/error_code_list.rst index f5537073b8bc..e72025ec2daf 100644 --- a/docs/source/error_code_list.rst +++ b/docs/source/error_code_list.rst @@ -1155,9 +1155,11 @@ See :ref:`overloading ` for more explanation. Check for overload signatures that cannot match [overload-cannot-match] -------------------------------------------------------------------------- -In the case of an overloaded function, if one of the signatures is never accessible, this error may occur. -An example where this can occur is with the utilization of object and int types. -Consider swapping the declaration of the two types so that the narrower signature is declared before the broader signature. +Warn if an ``@overload`` variant can never be matched, because an earlier +overload has a wider signature. For example, this can happen if the two +overloads accept the same parameters and each parameter on the first overload +has the same type or a wider type than the corresponding parameter on the second +overload. Example: