Skip to content

Commit

Permalink
[flow] Opaque type refinement only unwraps underlying type only if lo…
Browse files Browse the repository at this point in the history
…c == def_loc

Summary:
Fixed the bug accidentally introduced in D55411073. We check whether we can unwrap using existing mechanism.

Changelog: [errors] We fixed a bug where we incorrectly unwrapped the opaque type to the underlying representation in refinement

Reviewed By: jbrown215

Differential Revision: D55511251

fbshipit-source-id: 5fd96adf2d19d8ec2c566298f0ae01b6d7920e40
  • Loading branch information
SamChou19815 authored and facebook-github-bot committed Mar 29, 2024
1 parent 514f690 commit b2a1884
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/typing/type_filter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ let recurse_into_intersection =

let filter_opaque filter_fn reason ({ underlying_t; super_t; _ } as opq) =
match underlying_t with
| Some underlying_t -> begin
| Some underlying_t
when ALoc.source (loc_of_reason reason) = ALoc.source (def_loc_of_reason reason) -> begin
match filter_fn underlying_t with
| DefT (_, EmptyT) -> DefT (reason, EmptyT)
| t -> OpaqueT (reason, { opq with underlying_t = Some t })
end
| None -> begin
| _ -> begin
let super_t = Base.Option.value ~default:(DefT (reason, MixedT Mixed_everything)) super_t in
match filter_fn super_t with
| DefT (_, EmptyT) -> DefT (reason, EmptyT)
Expand Down

0 comments on commit b2a1884

Please sign in to comment.