diff --git a/scripts/setup.py b/scripts/setup.py index c8dd088f1f3..47948e5c92b 100755 --- a/scripts/setup.py +++ b/scripts/setup.py @@ -44,7 +44,7 @@ "lwt.5.6.1", "lwt_ppx.2.1.0", "ounit2-lwt.2.2.7", - "pyre-ast.0.1.9", + "pyre-ast.0.1.11", "mtime.1.4.0", "errpy.0.0.9", ] diff --git a/source/cpython_parser/pyreCPythonParser.ml b/source/cpython_parser/pyreCPythonParser.ml index e323b1db4e9..355fdb1e0c7 100644 --- a/source/cpython_parser/pyreCPythonParser.ml +++ b/source/cpython_parser/pyreCPythonParser.ml @@ -778,7 +778,18 @@ let statement = |> Node.create ~location; ] in - let function_def ~location ~name ~args ~body ~decorator_list ~returns ~type_comment ~context = + let function_def + ~location + ~name + ~args + ~body + ~decorator_list + ~returns + ~type_comment + ~type_params + ~context + = + ignore type_params (* TODO *); create_function_definition ~location ~async:false @@ -790,8 +801,18 @@ let statement = ~type_comment ~context in - let async_function_def ~location ~name ~args ~body ~decorator_list ~returns ~type_comment ~context + let async_function_def + ~location + ~name + ~args + ~body + ~decorator_list + ~returns + ~type_comment + ~type_params + ~context = + ignore type_params (* TODO *); create_function_definition ~location ~async:true @@ -803,7 +824,8 @@ let statement = ~type_comment ~context in - let class_def ~location ~name ~bases ~keywords ~body ~decorator_list ~context = + let class_def ~location ~name ~bases ~keywords ~body ~decorator_list ~type_params ~context = + ignore type_params (* TODO *); let base_arguments = List.append (List.map bases ~f:(fun arg -> convert_positional_argument arg, arg.Node.location)) @@ -865,6 +887,10 @@ let statement = in List.map targets ~f:create_assign_for_target in + let type_alias ~location ~name ~type_params ~value ~context = + ignore type_params (* TODO *); + assign ~location ~targets:[name] ~value ~type_comment:None ~context + in let aug_assign ~location ~target ~op ~value ~context:_ = [ Statement.AugmentedAssign { AugmentedAssign.target; operator = op; value } @@ -1034,6 +1060,7 @@ let statement = ~return ~delete ~assign + ~type_alias ~aug_assign ~ann_assign ~for_ @@ -1066,6 +1093,23 @@ let function_type ~argtypes ~returns = { FunctionSignature.parameter_annotations = argtypes; return_annotation = returns } +let type_param = + let raise_unimplemented location = + let { + Ast.Location.start = { Location.line; column }; + stop = { Location.line = end_line; column = end_column }; + } + = + location + in + raise (InternalError { Error.line; column; end_line; end_column; message = "Unimplemented" }) + in + let type_var ~location ~name:_ ~bound:_ = raise_unimplemented location in + let param_spec ~location ~name:_ = raise_unimplemented location in + let type_var_tuple ~location ~name:_ = raise_unimplemented location in + { PyreAst.TaglessFinal.TypeParam.type_var; param_spec; type_var_tuple } + + let specification = PyreAst.TaglessFinal.make ~argument @@ -1089,6 +1133,7 @@ let specification = ~position ~statement ~type_ignore + ~type_param ~unary_operator ~with_item () diff --git a/source/cpython_parser/test/expressionTest.ml b/source/cpython_parser/test/expressionTest.ml index 84e7e2d4b09..5ebb2e6941a 100644 --- a/source/cpython_parser/test/expressionTest.ml +++ b/source/cpython_parser/test/expressionTest.ml @@ -360,6 +360,7 @@ let test_fstring = format (Expression.Name (Name.Identifier "w")); literal "."; format (Expression.Name (Name.Identifier "p")); + literal ""; ]); ]; labeled_test_case __FUNCTION__ __LINE__ diff --git a/source/cpython_parser/test/locationTest.ml b/source/cpython_parser/test/locationTest.ml index d93ae0d3ff3..86501ff1402 100644 --- a/source/cpython_parser/test/locationTest.ml +++ b/source/cpython_parser/test/locationTest.ml @@ -2890,7 +2890,7 @@ let test_string_locations = ~start:(1, 0) ~stop:(1, 6) (Expression.FormatString - [Substring.Literal (node ~start:(1, 0) ~stop:(1, 6) "foo")]))); + [Substring.Literal (node ~start:(1, 2) ~stop:(1, 5) "foo")]))); ]; labeled_test_case __FUNCTION__ __LINE__ @@ assert_parsed @@ -2906,7 +2906,7 @@ let test_string_locations = ~stop:(1, 10) (Expression.FormatString [ - Substring.Literal (node ~start:(1, 0) ~stop:(1, 10) "foo "); + Substring.Literal (node ~start:(1, 2) ~stop:(1, 6) "foo "); Substring.Format { format_spec = None; @@ -2931,7 +2931,7 @@ let test_string_locations = ~start:(1, 0) ~stop:(1, 13) (Expression.FormatString - [Substring.Literal (node ~start:(1, 0) ~stop:(1, 13) "foobar")]))); + [Substring.Literal (node ~start:(1, 2) ~stop:(1, 12) "foobar")]))); ]; labeled_test_case __FUNCTION__ __LINE__ @@ assert_parsed @@ -3020,7 +3020,7 @@ let test_string_locations = ~stop:(3, 3) (Expression.FormatString [ - Substring.Literal (node ~start:(1, 0) ~stop:(3, 3) "\n"); + Substring.Literal (node ~start:(1, 4) ~stop:(2, 0) "\n"); Substring.Format { format_spec = None; @@ -3031,7 +3031,7 @@ let test_string_locations = (Expression.Constant (Constant.String (StringLiteral.create "a"))); }; - Substring.Literal (node ~start:(1, 0) ~stop:(3, 3) "b\n"); + Substring.Literal (node ~start:(2, 5) ~stop:(3, 0) "b\n"); ]))); ]; ] diff --git a/source/interprocedural_analyses/taint/test/integration/format.py.models b/source/interprocedural_analyses/taint/test/integration/format.py.models index e6d5bfc910e..f0bff38ad9b 100644 --- a/source/interprocedural_analyses/taint/test/integration/format.py.models +++ b/source/interprocedural_analyses/taint/test/integration/format.py.models @@ -548,7 +548,7 @@ { "always-via": "tito" } ], "tito_positions": [ - { "line": 37, "start": 11, "end": 38 }, + { "line": 37, "start": 19, "end": 36 }, { "line": 37, "start": 21, "end": 35 } ], "origin": {