Skip to content

Commit

Permalink
Fix line number for type error when unpacking a tuple.
Browse files Browse the repository at this point in the history
Reviewed By: grievejia

Differential Revision: D24775172

fbshipit-source-id: 08111e533729e71487680425cb9fda873c8d9c01
  • Loading branch information
pradeep90 authored and facebook-github-bot committed Nov 6, 2020
1 parent d0ad94c commit e3ddbf1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
9 changes: 2 additions & 7 deletions analysis/attributeResolution.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3741,16 +3741,11 @@ class base class_metadata_environment dependency =
Argument.WithPosition.resolved = Tuple (Bounded (Concrete tuple_parameters));
kind = SingleStar;
position;
_;
expression;
} ->
let unpacked_arguments =
List.map tuple_parameters ~f:(fun resolved ->
{
Argument.WithPosition.expression = None;
kind = Positional;
resolved;
position;
})
{ Argument.WithPosition.expression; kind = Positional; resolved; position })
in
List.concat [List.rev unpacked_arguments; sofar]
| _ -> argument :: sofar
Expand Down
11 changes: 11 additions & 0 deletions analysis/test/integration/methodTest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,17 @@ let test_check_method_parameters context =
"Revealed type [-1]: Revealed type for `test.Foo().s` is \
`List[typing.StaticMethod[typing.Callable(Foo.s)[[], None]]]`.";
];
assert_type_errors
~include_line_numbers:true
{|
xs = (1, 2, 3)
def foo(x: int, y: int, z: str) -> None: ...
foo(*xs)
|}
[
"4: Incompatible parameter type [6]: Expected `str` for 3rd positional only parameter to \
call `foo` but got `int`.";
];
()
Expand Down

0 comments on commit e3ddbf1

Please sign in to comment.