Skip to content

Commit

Permalink
[flow][debug] Add debug log when we decide that a type is cyclic
Browse files Browse the repository at this point in the history
Summary:
This is normally logged in flow_js_utils, where we add most errors. However, this one has to exist in context.ml to avoid cyclic modules, and it's missing the log. Logging this can help us debug why something is considered to be cyclic under LTI 2.0

Changelog: [internal]

Reviewed By: panagosg7

Differential Revision: D55775465

fbshipit-source-id: 6587f5b4cd4d57a3161e31cc4120a636b9ee8470
  • Loading branch information
SamChou19815 authored and facebook-github-bot committed Apr 10, 2024
1 parent 9de0e65 commit fa9e555
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/typing/context.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,18 @@ let find_root_id cx id = Type.Constraint.find_root_id cx.ccx.sig_cx.graph id
let on_cyclic_tvar_error cx reason =
let msg = Error_message.(ETrivialRecursiveDefinition (Reason.loc_of_reason reason, reason)) in
let error = Flow_error.error_of_msg ~trace_reasons:[] ~source_file:cx.file msg in
if is_verbose cx then
Utils_js.prerr_endlinef
"\nCyclic type: %s"
(Reason.dump_reason
~strip_root:
( if should_strip_root cx then
Some (root cx)
else
None
)
reason
);
add_error cx error;
Type.AnyT.error reason

Expand Down

0 comments on commit fa9e555

Please sign in to comment.