You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary:
If only one overload has a parameter count that is compatible with a call's argument count, we should take that as the matching overload even if the call produces errors.
This gives us more precise return types and better error messages.
In some cases, this increases the number of errors because a single "No matching overload" error is replaced with multiple errors about specific parameters. IMO this is a good change.
Fixes#2833.
Reviewed By: stroxler
Differential Revision: D97394258
fbshipit-source-id: 737258f4a3f2f56d287efd3240bec5c7052a8db3
Copy file name to clipboardExpand all lines: conformance/third_party/conformance.exp
+15-15Lines changed: 15 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -9073,24 +9073,24 @@
9073
9073
},
9074
9074
{
9075
9075
"code": -2,
9076
-
"column": 11,
9077
-
"concise_description": "No matching overload found for function `example1_1` called with arguments: (Literal[1], Literal[1])",
9078
-
"description": "No matching overload found for function `example1_1` called with arguments: (Literal[1], Literal[1])\n Possible overloads:\n (x: int, y: str) -> int [closest match]\n (x: str) -> str",
9076
+
"column": 15,
9077
+
"concise_description": "Argument `Literal[1]` is not assignable to parameter `y` with type `str` in function `example1_1`",
9078
+
"description": "Argument `Literal[1]` is not assignable to parameter `y` with type `str` in function `example1_1`",
9079
9079
"line": 46,
9080
-
"name": "no-matching-overload",
9080
+
"name": "bad-argument-type",
9081
9081
"severity": "error",
9082
-
"stop_column": 17,
9082
+
"stop_column": 16,
9083
9083
"stop_line": 46
9084
9084
},
9085
9085
{
9086
9086
"code": -2,
9087
-
"column": 11,
9088
-
"concise_description": "No matching overload found for function `example1_1` called with arguments: (Literal[1])",
9089
-
"description": "No matching overload found for function `example1_1` called with arguments: (Literal[1])\n Possible overloads:\n (x: int, y: str) -> int\n (x: str) -> str [closest match]",
9087
+
"column": 12,
9088
+
"concise_description": "Argument `Literal[1]` is not assignable to parameter `x` with type `str` in function `example1_1`",
9089
+
"description": "Argument `Literal[1]` is not assignable to parameter `x` with type `str` in function `example1_1`",
9090
9090
"line": 51,
9091
-
"name": "no-matching-overload",
9091
+
"name": "bad-argument-type",
9092
9092
"severity": "error",
9093
-
"stop_column": 14,
9093
+
"stop_column": 13,
9094
9094
"stop_line": 51
9095
9095
},
9096
9096
{
@@ -11738,13 +11738,13 @@
11738
11738
},
11739
11739
{
11740
11740
"code": -2,
11741
-
"column": 11,
11742
-
"concise_description": "No matching overload found for function `ExtraMovie.__init__` called with arguments: (name=Literal['No Country for Old Men'], language=Literal['English'])",
11743
-
"description": "No matching overload found for function `ExtraMovie.__init__` called with arguments: (name=Literal['No Country for Old Men'], language=Literal['English'])\n Possible overloads:\n (*, name: str, **int) -> None [closest match]\n (__map: ExtraMovie, /, *, name: str = ..., **int) -> None",
11741
+
"column": 52,
11742
+
"concise_description": "Keyword argument `language` with type `Literal['English']` is not assignable to kwargs type `int` in function `ExtraMovie.__init__`",
11743
+
"description": "Keyword argument `language` with type `Literal['English']` is not assignable to kwargs type `int` in function `ExtraMovie.__init__`",
c.setdefault("x", 0.0) # E: `float` is not assignable to parameter `default` with type `int`
949
949
c.setdefault("x") # E: No matching overload
950
-
c.setdefault(s, 0) # E: No matching overload
950
+
c.setdefault(s, 0) # E: `str` is not assignable to parameter `key` with type `Literal['x']`
951
951
"#,
952
952
);
953
953
@@ -963,7 +963,7 @@ class D(TypedDict):
963
963
def f(c: C, d: D):
964
964
c.setdefault("x", 0) # E: `Literal['x']` is not assignable to parameter `k` with type `Never`
965
965
d.setdefault("x", 0)
966
-
d.setdefault("y", "oops") # E: No matching overload
966
+
d.setdefault("y", "oops") # E: `Literal['y']` is not assignable to parameter `key` with type `Literal['x']` # E: `Literal['oops']` is not assignable to parameter `default` with type `int`
967
967
"#,
968
968
);
969
969
@@ -986,7 +986,7 @@ testcase!(
986
986
from typing import TypedDict
987
987
class C(TypedDict):
988
988
x: int
989
-
C(0) # E: No matching overload found for function `C.__init__`
989
+
C(0) # E: `Literal[0]` is not assignable to parameter `__map` with type `C`
990
990
"#,
991
991
);
992
992
@@ -1258,7 +1258,7 @@ from typing import TypedDict
1258
1258
class Movie(TypedDict, extra_items=int):
1259
1259
name: str
1260
1260
good_movie = Movie(name='Toy Story', year=1995)
1261
-
bad_movie = Movie(name='Toy Story', studio='Pixar') # E: No matching overload found for function `Movie.__init__`
1261
+
bad_movie = Movie(name='Toy Story', studio='Pixar') # E: `Literal['Pixar']` is not assignable to kwargs type `int`
0 commit comments