Skip to content

Commit

Permalink
special forms of UseT
Browse files Browse the repository at this point in the history
Summary:
"This type is incompatible with" errors have the potential to be a lot more descriptive, if we can keep track of what caused us to flow one def type into another def type.

This diff is a lot of boilerplate nonsense to add an "op" property to `UseT`, and a couple of examples of those ops being set when we deconstruct some other type into the final `Type.t -> UseT Type.t`.

Reviewed By: avikchaudhuri

Differential Revision: D3208938

fb-gh-sync-id: 4fc3fafb4a01d4bdf8d490a71ab99e2975ceb76f
fbshipit-source-id: 4fc3fafb4a01d4bdf8d490a71ab99e2975ceb76f
  • Loading branch information
mroch authored and Facebook Github Bot 7 committed Apr 26, 2016
1 parent 00898cf commit 7b8c3ae
Show file tree
Hide file tree
Showing 38 changed files with 315 additions and 268 deletions.
5 changes: 3 additions & 2 deletions src/typing/debug_js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ and _json_of_use_t_impl json_cx t = Hh_json.(
"kind", JSON_String (string_of_use_ctor t)
] @
match t with
| UseT t -> [
| UseT (op, t) -> [
"use", JSON_String (string_of_use_op op);
"type", _json_of_t json_cx t
]

Expand Down Expand Up @@ -941,7 +942,7 @@ and dump_use_t cx t =
dump_use_t_ ISet.empty cx t

and dump_use_t_ stack cx t = match t with
| UseT t -> dump_t_ stack cx t
| UseT (_, t) -> dump_t_ stack cx t

| SetPropT (_, (_, n), t) ->
spf "SetPropT(%s: %s)" n (dump_t_ stack cx t)
Expand Down
2 changes: 1 addition & 1 deletion src/typing/flow_error.ml
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ end = struct

(* for when a t has been extracted from a use_t *)
let flow_err_use_t cx trace msg ?extra lower upper =
flow_err cx trace msg ?extra lower (UseT upper)
flow_err cx trace msg ?extra lower (UseT (UnknownUse, upper))

end

Expand Down
Loading

0 comments on commit 7b8c3ae

Please sign in to comment.