Skip to content

Commit

Permalink
Add extended reasons function parameters
Browse files Browse the repository at this point in the history
Summary: Records flow from parameter hints into parameters.

Reviewed By: madgen

Differential Revision: D56703905

fbshipit-source-id: 0cfc7474858e8a986acb9bbcd08d4add35c49c06
  • Loading branch information
Michael Thomas authored and facebook-github-bot committed May 3, 2024
1 parent 8b6d275 commit ac53274
Show file tree
Hide file tree
Showing 5 changed files with 221 additions and 22 deletions.
7 changes: 7 additions & 0 deletions hphp/hack/src/typing/typing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8526,6 +8526,13 @@ end = struct
in
(env, Some te, ty1)
in
(* Update the reason to record the flow from the parameter hint into the parameter *)
let ty1 =
Prov.(
update ty1 ~env ~f:(fun from ->
flow ~from ~into:(Typing_reason.Rwitness param.param_pos)))
in
let param_te = Option.map param_te ~f:(fun (_, pos, e) -> (ty1, pos, e)) in
let (env, user_attributes) =
User_attribute.attributes_check_def
env
Expand Down
66 changes: 60 additions & 6 deletions hphp/hack/test/extended_reasons/assign_local.php.exp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ error: Typing[4110] Invalid argument [1]
{
"Rflow":[
{
"Rhint":[{"filename":"assign_local.php","line":8,"char_start":16,"char_end":20}]
"Rflow":[
{
"Rhint":[{"filename":"assign_local.php","line":8,"char_start":16,"char_end":20}]
},
{
"Rwitness":[{"filename":"assign_local.php","line":8,"char_start":22,"char_end":23}]
}
]
},
{
"Rwitness":[{"filename":"assign_local.php","line":9,"char_start":3,"char_end":4}]
Expand Down Expand Up @@ -59,7 +66,14 @@ error: Typing[4110] Invalid argument [1]
{
"Rflow":[
{
"Rhint":[{"filename":"assign_local.php","line":8,"char_start":16,"char_end":20}]
"Rflow":[
{
"Rhint":[{"filename":"assign_local.php","line":8,"char_start":16,"char_end":20}]
},
{
"Rwitness":[{"filename":"assign_local.php","line":8,"char_start":22,"char_end":23}]
}
]
},
{
"Rwitness":[{"filename":"assign_local.php","line":9,"char_start":3,"char_end":4}]
Expand Down Expand Up @@ -99,6 +113,10 @@ error: Typing[4110] Invalid argument [1]
"Rhint":[{"filename":"assign_local.php","line":8,"char_start":16,"char_end":20}]
},
{"Fwd":[]},
{
"Rwitness":[{"filename":"assign_local.php","line":8,"char_start":22,"char_end":23}]
},
{"Fwd":[]},
{
"Rwitness":[{"filename":"assign_local.php","line":9,"char_start":3,"char_end":4}]
},
Expand Down Expand Up @@ -148,7 +166,14 @@ error: Typing[4110] Invalid argument [1]
{
"Rflow":[
{
"Rhint":[{"filename":"assign_local.php","line":13,"char_start":16,"char_end":20}]
"Rflow":[
{
"Rhint":[{"filename":"assign_local.php","line":13,"char_start":16,"char_end":20}]
},
{
"Rwitness":[{"filename":"assign_local.php","line":13,"char_start":22,"char_end":23}]
}
]
},
{
"Rwitness":[{"filename":"assign_local.php","line":14,"char_start":3,"char_end":4}]
Expand Down Expand Up @@ -203,7 +228,14 @@ error: Typing[4110] Invalid argument [1]
{
"Rflow":[
{
"Rhint":[{"filename":"assign_local.php","line":13,"char_start":16,"char_end":20}]
"Rflow":[
{
"Rhint":[{"filename":"assign_local.php","line":13,"char_start":16,"char_end":20}]
},
{
"Rwitness":[{"filename":"assign_local.php","line":13,"char_start":22,"char_end":23}]
}
]
},
{
"Rwitness":[{"filename":"assign_local.php","line":14,"char_start":3,"char_end":4}]
Expand Down Expand Up @@ -248,6 +280,10 @@ error: Typing[4110] Invalid argument [1]
"Rhint":[{"filename":"assign_local.php","line":13,"char_start":16,"char_end":20}]
},
{"Fwd":[]},
{
"Rwitness":[{"filename":"assign_local.php","line":13,"char_start":22,"char_end":23}]
},
{"Fwd":[]},
{
"Rwitness":[{"filename":"assign_local.php","line":14,"char_start":3,"char_end":4}]
},
Expand Down Expand Up @@ -308,7 +344,14 @@ error: Typing[4110] Invalid argument [1]
{
"Rflow":[
{
"Rhint":[{"filename":"assign_local.php","line":19,"char_start":16,"char_end":20}]
"Rflow":[
{
"Rhint":[{"filename":"assign_local.php","line":19,"char_start":16,"char_end":20}]
},
{
"Rwitness":[{"filename":"assign_local.php","line":19,"char_start":22,"char_end":23}]
}
]
},
{
"Rwitness":[{"filename":"assign_local.php","line":20,"char_start":3,"char_end":4}]
Expand Down Expand Up @@ -370,7 +413,14 @@ error: Typing[4110] Invalid argument [1]
{
"Rflow":[
{
"Rhint":[{"filename":"assign_local.php","line":19,"char_start":16,"char_end":20}]
"Rflow":[
{
"Rhint":[{"filename":"assign_local.php","line":19,"char_start":16,"char_end":20}]
},
{
"Rwitness":[{"filename":"assign_local.php","line":19,"char_start":22,"char_end":23}]
}
]
},
{
"Rwitness":[{"filename":"assign_local.php","line":20,"char_start":3,"char_end":4}]
Expand Down Expand Up @@ -420,6 +470,10 @@ error: Typing[4110] Invalid argument [1]
"Rhint":[{"filename":"assign_local.php","line":19,"char_start":16,"char_end":20}]
},
{"Fwd":[]},
{
"Rwitness":[{"filename":"assign_local.php","line":19,"char_start":22,"char_end":23}]
},
{"Fwd":[]},
{
"Rwitness":[{"filename":"assign_local.php","line":20,"char_start":3,"char_end":4}]
},
Expand Down
44 changes: 40 additions & 4 deletions hphp/hack/test/extended_reasons/fn_call.php.exp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ error: Typing[4110] Invalid argument [1]
"Rflow":[
{
"Rflow":[
{"Rhint":[{"filename":"fn_call.php","line":5,"char_start":25,"char_end":27}]},
{
"Rflow":[
{"Rhint":[{"filename":"fn_call.php","line":5,"char_start":25,"char_end":27}]},
{
"Rwitness":[{"filename":"fn_call.php","line":5,"char_start":29,"char_end":30}]
}
]
},
{"Rwitness":[{"filename":"fn_call.php","line":6,"char_start":7,"char_end":8}]}
]
},
Expand Down Expand Up @@ -41,7 +48,14 @@ error: Typing[4110] Invalid argument [1]
"Rflow":[
{
"Rflow":[
{"Rhint":[{"filename":"fn_call.php","line":5,"char_start":25,"char_end":27}]},
{
"Rflow":[
{"Rhint":[{"filename":"fn_call.php","line":5,"char_start":25,"char_end":27}]},
{
"Rwitness":[{"filename":"fn_call.php","line":5,"char_start":29,"char_end":30}]
}
]
},
{"Rwitness":[{"filename":"fn_call.php","line":6,"char_start":7,"char_end":8}]}
]
},
Expand All @@ -67,6 +81,10 @@ error: Typing[4110] Invalid argument [1]
[
{"Rhint":[{"filename":"fn_call.php","line":5,"char_start":25,"char_end":27}]},
{"Fwd":[]},
{
"Rwitness":[{"filename":"fn_call.php","line":5,"char_start":29,"char_end":30}]
},
{"Fwd":[]},
{"Rwitness":[{"filename":"fn_call.php","line":6,"char_start":7,"char_end":8}]},
{"Fwd":[]},
{"Prj_symm_fn_arg":[0,0,{"Contravariant":[]}]},
Expand Down Expand Up @@ -99,7 +117,14 @@ error: Typing[4110] Invalid argument [1]
"Rflow":[
{
"Rflow":[
{"Rhint":[{"filename":"fn_call.php","line":5,"char_start":14,"char_end":19}]},
{
"Rflow":[
{"Rhint":[{"filename":"fn_call.php","line":5,"char_start":14,"char_end":19}]},
{
"Rwitness":[{"filename":"fn_call.php","line":5,"char_start":21,"char_end":22}]
}
]
},
{
"Rwitness":[{"filename":"fn_call.php","line":6,"char_start":11,"char_end":12}]
}
Expand Down Expand Up @@ -134,7 +159,14 @@ error: Typing[4110] Invalid argument [1]
"Rflow":[
{
"Rflow":[
{"Rhint":[{"filename":"fn_call.php","line":5,"char_start":14,"char_end":19}]},
{
"Rflow":[
{"Rhint":[{"filename":"fn_call.php","line":5,"char_start":14,"char_end":19}]},
{
"Rwitness":[{"filename":"fn_call.php","line":5,"char_start":21,"char_end":22}]
}
]
},
{
"Rwitness":[{"filename":"fn_call.php","line":6,"char_start":11,"char_end":12}]
}
Expand Down Expand Up @@ -162,6 +194,10 @@ error: Typing[4110] Invalid argument [1]
[
{"Rhint":[{"filename":"fn_call.php","line":5,"char_start":14,"char_end":19}]},
{"Fwd":[]},
{
"Rwitness":[{"filename":"fn_call.php","line":5,"char_start":21,"char_end":22}]
},
{"Fwd":[]},
{
"Rwitness":[{"filename":"fn_call.php","line":6,"char_start":11,"char_end":12}]
},
Expand Down
Loading

0 comments on commit ac53274

Please sign in to comment.