File tree Expand file tree Collapse file tree 5 files changed +34
-7
lines changed Expand file tree Collapse file tree 5 files changed +34
-7
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,8 @@ let load_lib_files files =
83
83
locs_to_dirtify = [] ;
84
84
}
85
85
in
86
- Merge_js. merge_lib_files ~sig_opts asts |> snd
86
+ let (_, _, master_cx) = Merge_js. merge_lib_files ~sig_opts asts in
87
+ master_cx
87
88
88
89
let stub_metadata ~root ~checked =
89
90
{
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ let load_lib_files ~ccx ~options ~reader files =
45
45
let (builtin_exports, master_cx, cx_opt) =
46
46
if ok then
47
47
let sig_opts = Type_sig_options. builtin_options options in
48
- let (builtins, master_cx) = Merge_js. merge_lib_files ~sig_opts ordered_asts in
48
+ let (builtins, builtin_errors, master_cx) = Merge_js. merge_lib_files ~sig_opts ordered_asts in
49
49
let cx_opt =
50
50
match master_cx with
51
51
| Context. EmptyMasterContext -> None
@@ -66,6 +66,7 @@ let load_lib_files ~ccx ~options ~reader files =
66
66
(fun mref -> Context. MissingModule mref)
67
67
mk_builtins
68
68
in
69
+ Context. reset_errors cx builtin_errors;
69
70
Some cx
70
71
in
71
72
(Exports. of_builtins builtins, master_cx, cx_opt)
Original file line number Diff line number Diff line change @@ -181,7 +181,8 @@ end = struct
181
181
locs_to_dirtify = [] ;
182
182
}
183
183
in
184
- Merge_js. merge_lib_files ~sig_opts asts |> snd
184
+ let (_, _, master_cx) = Merge_js. merge_lib_files ~sig_opts asts in
185
+ master_cx
185
186
186
187
let master_cx_ref = ref None
187
188
Original file line number Diff line number Diff line change @@ -866,14 +866,36 @@ let module_type_copied dst_cx src_cx ({ Type.module_export_types; module_global_
866
866
{ m with Type. module_global_types_tmap }
867
867
868
868
let merge_lib_files ~sig_opts ordered_asts =
869
- let (_builtin_errors , builtin_locs, builtins) =
869
+ let (builtin_errors , builtin_locs, builtins) =
870
870
Type_sig_utils. parse_and_pack_builtins sig_opts ordered_asts
871
871
in
872
+ let builtin_errors =
873
+ builtin_errors
874
+ |> Base.List. filter_map ~f: (function
875
+ | Type_sig. SigError e ->
876
+ let e =
877
+ Signature_error. map
878
+ (fun l -> l |> Type_sig_collections.Locs. get builtin_locs |> ALoc. of_loc)
879
+ e
880
+ in
881
+ let msg = Error_message. ESignatureVerification e in
882
+ let source_file =
883
+ Base.Option. value_exn
884
+ (msg |> Error_message. loc_of_msg |> Base.Option. bind ~f: ALoc. source)
885
+ in
886
+ Some (Flow_error. error_of_msg ~source_file msg)
887
+ | Type_sig. CheckError -> None
888
+ )
889
+ |> Flow_error.ErrorSet. of_list
890
+ in
872
891
match ordered_asts with
873
- | [] -> (builtins, Context. EmptyMasterContext )
892
+ | [] -> (builtins, builtin_errors, Context. EmptyMasterContext )
874
893
| fst_ast :: _ ->
875
894
let builtin_leader_file_key = Base.Option. value_exn (fst_ast |> fst |> Loc. source) in
876
- (builtins, Context. NonEmptyMasterContext { builtin_leader_file_key; builtin_locs; builtins })
895
+ ( builtins,
896
+ builtin_errors,
897
+ Context. NonEmptyMasterContext { builtin_leader_file_key; builtin_locs; builtins }
898
+ )
877
899
878
900
let mk_builtins metadata master_cx =
879
901
match master_cx with
Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ val copy_into :
28
28
val merge_lib_files :
29
29
sig_opts :Type_sig_options .t ->
30
30
(Loc .t , Loc .t ) Flow_ast.Program .t list ->
31
- Type_sig_collections.Locs .index Packed_type_sig.Builtins .t * Context .master_context
31
+ Type_sig_collections.Locs .index Packed_type_sig.Builtins .t
32
+ * Flow_error.ErrorSet .t
33
+ * Context .master_context
32
34
33
35
val mk_builtins : Context .metadata -> Context .master_context -> Context .t -> Builtins .t
You can’t perform that action at this time.
0 commit comments