Skip to content

Commit

Permalink
[flow][refactor][EZ] Replace unknown_elem_empty_array_desc with `RE…
Browse files Browse the repository at this point in the history
…mptyArrayElement`

Summary:
Resolving the TODO is easier than you think...

See https://github.com/facebook/flow/blob/84355f3aebd4db3159f342d3d2e95b40100a1671/src/common/reason.ml#L549

Changelog: [internal]

Reviewed By: panagosg7

Differential Revision: D56608187

fbshipit-source-id: 1b74073aa053bb1b3cca137d7a11ab8b3f04d0f1
  • Loading branch information
SamChou19815 authored and facebook-github-bot committed Apr 26, 2024
1 parent ef41bc5 commit 6eccf3c
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 8 deletions.
3 changes: 0 additions & 3 deletions src/common/reason.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1350,9 +1350,6 @@ let mk_initial_arguments_reason =

let mk_pattern_reason ((loc, _) as patt) = mk_reason (RCode (code_desc_of_pattern patt)) loc

(* TODO: replace RCustom descriptions with proper descriptions *)
let unknown_elem_empty_array_desc = RCustom "unknown element type of empty array"

(* Classifies a reason description. These classifications can be used to
* implement various asthetic behaviors in error messages when we would like to
* distinguish between different error "classes".
Expand Down
2 changes: 0 additions & 2 deletions src/common/reason.mli
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,6 @@ val mk_initial_arguments_reason :

val mk_pattern_reason : (ALoc.t, ALoc.t) Flow_ast.Pattern.t -> reason

val unknown_elem_empty_array_desc : reason_desc

val invalidate_rtype_alias : 'loc virtual_reason_desc -> 'loc virtual_reason_desc

val code_desc_of_expression : wrap:bool -> ('a, 'b) Flow_ast.Expression.t -> string
Expand Down
2 changes: 1 addition & 1 deletion src/typing/env_resolution.ml
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ let rec resolve_binding cx reason loc b =
(func_type, use_op)
| Root (EmptyArray { array_providers; arr_loc }) ->
let (elem_t, tuple_view, reason) =
let element_reason = mk_reason Reason.unknown_elem_empty_array_desc loc in
let element_reason = mk_reason REmptyArrayElement loc in
if ALocSet.cardinal array_providers > 0 then (
let ts =
ALocSet.elements array_providers
Expand Down
4 changes: 2 additions & 2 deletions src/typing/statement.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2505,7 +2505,7 @@ module Make

and empty_array cx loc =
let reason = mk_reason REmptyArrayLit loc in
let element_reason = mk_reason Reason.unknown_elem_empty_array_desc loc in
let element_reason = mk_reason REmptyArrayElement loc in
let (has_hint, lazy_hint) = Type_env.get_hint cx loc in
(* empty array, analogous to object with implicit properties *)
let elemt =
Expand Down Expand Up @@ -2704,7 +2704,7 @@ module Make
(match elements with
| [] when Context.typing_mode cx <> Context.CheckingMode ->
let reason = mk_reason REmptyArrayLit loc in
let element_reason = mk_reason Reason.unknown_elem_empty_array_desc loc in
let element_reason = mk_reason REmptyArrayElement loc in
let elem_t = Context.mk_placeholder cx element_reason in
( ( loc,
DefT
Expand Down

0 comments on commit 6eccf3c

Please sign in to comment.