Skip to content

Commit 9704adf

Browse files
authored
Merge pull request #5045 from rescript-lang/test_case
clean up handling of small soundness issue
2 parents 1869fd3 + b6d9190 commit 9704adf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+4803
-4729
lines changed

jscomp/bsb/bsb_arg.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(* Copyright (C) 2020- Hongbo Zhang, Authors of ReScript
1+
(* Copyright (C) 2020 - Hongbo Zhang, Authors of ReScript
22
*
33
* This program is free software: you can redistribute it and/or modify
44
* it under the terms of the GNU Lesser General Public License as published by

jscomp/bsb/bsb_build_schemas.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript
1+
(* Copyright (C) 2017 - Hongbo Zhang, Authors of ReScript
22
*
33
* This program is free software: you can redistribute it and/or modify
44
* it under the terms of the GNU Lesser General Public License as published by

jscomp/bsb/bsb_build_util.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
2-
*
1+
(* Copyright (C) 2015 - 2016 Bloomberg Finance L.P.
2+
* Copyright (C) 2017 - Hongbo Zhang, Authors of ReScript
33
* This program is free software: you can redistribute it and/or modify
44
* it under the terms of the GNU Lesser General Public License as published by
55
* the Free Software Foundation, either version 3 of the License, or

jscomp/bsb/bsb_build_util.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
2-
*
2+
* Copyright (C) 2017 - Hongbo Zhang, Authors of ReScript
33
* This program is free software: you can redistribute it and/or modify
44
* it under the terms of the GNU Lesser General Public License as published by
55
* the Free Software Foundation, either version 3 of the License, or

jscomp/bsb/bsb_config.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
2-
*
2+
* Copyright (C) 2017 - Hongbo Zhang, Authors of ReScript
33
* This program is free software: you can redistribute it and/or modify
44
* it under the terms of the GNU Lesser General Public License as published by
55
* the Free Software Foundation, either version 3 of the License, or

jscomp/bsb/bsb_config.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
2-
*
1+
(* Copyright (C) 2015 - 2016 Bloomberg Finance L.P.
2+
* Copyright (C) 2017 - Hongbo Zhang, Authors of ReScript
33
* This program is free software: you can redistribute it and/or modify
44
* it under the terms of the GNU Lesser General Public License as published by
55
* the Free Software Foundation, either version 3 of the License, or

jscomp/bsb/bsb_config_parse.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
2-
*
1+
(* Copyright (C) 2015 - 2016 Bloomberg Finance L.P.
2+
* Copyright (C) 2017 - Hongbo Zhang, Authors of ReScript
33
* This program is free software: you can redistribute it and/or modify
44
* it under the terms of the GNU Lesser General Public License as published by
55
* the Free Software Foundation, either version 3 of the License, or

jscomp/bsb/bsb_config_parse.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
2-
*
2+
* Copyright (C) 2017 - Hongbo Zhang, Authors of ReScript
33
* This program is free software: you can redistribute it and/or modify
44
* it under the terms of the GNU Lesser General Public License as published by
55
* the Free Software Foundation, either version 3 of the License, or

jscomp/bsb/bsb_config_types.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
2-
*
2+
* Copyright (C) 2017 - Hongbo Zhang, Authors of ReScript
33
* This program is free software: you can redistribute it and/or modify
44
* it under the terms of the GNU Lesser General Public License as published by
55
* the Free Software Foundation, either version 3 of the License, or

jscomp/bsb/bsb_db_util.ml

Lines changed: 55 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
3-
*
3+
* Copyright (C) 2017 - Hongbo Zhang, Authors of ReScript
44
* This program is free software: you can redistribute it and/or modify
55
* it under the terms of the GNU Lesser General Public License as published by
66
* the Free Software Foundation, either version 3 of the License, or
@@ -24,7 +24,7 @@
2424
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2525
type module_info = Bsb_db.module_info
2626
type t = Bsb_db.map
27-
(* type case = Bsb_db.case *)
27+
2828

2929

3030

@@ -87,54 +87,56 @@ let add_basename
8787
?(error_on_invalid_suffix)
8888
basename : t =
8989
if is_editor_temporary_files basename then map
90-
else
91-
let info = ref Bsb_db.Impl in
92-
let syntax_kind = ref Bsb_db.Ml in
93-
let invalid_suffix = ref false in
94-
let file_suffix = Ext_filename.get_extension_maybe basename in
95-
(match () with
96-
| _ when file_suffix = Literals.suffix_ml ->
97-
()
98-
| _ when file_suffix = Literals.suffix_res ->
99-
syntax_kind := Res
100-
| _ when file_suffix = Literals.suffix_re ->
101-
syntax_kind := Reason
102-
| _ when file_suffix = Literals.suffix_mli ->
103-
info := Intf
104-
| _ when file_suffix = Literals.suffix_resi ->
105-
info := Intf;
106-
syntax_kind := Res
107-
| _ when file_suffix = Literals.suffix_rei ->
108-
info := Intf;
109-
syntax_kind := Reason
110-
| _ ->
111-
invalid_suffix := true
112-
);
113-
let info= !info in
114-
let syntax_kind = !syntax_kind in
115-
let invalid_suffix = !invalid_suffix in
116-
if invalid_suffix then
117-
match error_on_invalid_suffix with
118-
| None -> map
119-
| Some loc ->
120-
Bsb_exception.errorf ~loc:loc
121-
"invalid suffix %s" basename
122-
else
123-
match Ext_filename.as_module ~basename:(Filename.basename basename) with
124-
| None ->
125-
Bsb_log.warn warning_unused_file basename dir;
126-
map
127-
| Some {module_name; case} ->
128-
let name_sans_extension =
129-
Filename.concat dir (Ext_filename.chop_extension_maybe basename) in
130-
let dir = Filename.dirname name_sans_extension in
131-
Map_string.adjust
132-
map
133-
module_name
134-
(fun opt_module_info ->
135-
match opt_module_info with
136-
| None ->
137-
{dir ; name_sans_extension ; info ; syntax_kind ; case }
138-
| Some x ->
139-
check x name_sans_extension case syntax_kind info
140-
)
90+
else
91+
begin
92+
let info = ref Bsb_db.Impl in
93+
let syntax_kind = ref Bsb_db.Ml in
94+
let invalid_suffix = ref false in
95+
let file_suffix = Ext_filename.get_extension_maybe basename in
96+
begin match () with
97+
| _ when file_suffix = Literals.suffix_ml ->
98+
()
99+
| _ when file_suffix = Literals.suffix_res ->
100+
syntax_kind := Res
101+
| _ when file_suffix = Literals.suffix_re ->
102+
syntax_kind := Reason
103+
| _ when file_suffix = Literals.suffix_mli ->
104+
info := Intf
105+
| _ when file_suffix = Literals.suffix_resi ->
106+
info := Intf;
107+
syntax_kind := Res
108+
| _ when file_suffix = Literals.suffix_rei ->
109+
info := Intf;
110+
syntax_kind := Reason
111+
| _ ->
112+
invalid_suffix := true
113+
end;
114+
let info= !info in
115+
let syntax_kind = !syntax_kind in
116+
let invalid_suffix = !invalid_suffix in
117+
if invalid_suffix then
118+
match error_on_invalid_suffix with
119+
| None -> map
120+
| Some loc ->
121+
Bsb_exception.errorf ~loc:loc
122+
"invalid suffix %s" basename
123+
else
124+
match Ext_filename.as_module ~basename:(Filename.basename basename) with
125+
| None ->
126+
Bsb_log.warn warning_unused_file basename dir;
127+
map
128+
| Some {module_name; case} ->
129+
let name_sans_extension =
130+
Filename.concat dir (Ext_filename.chop_extension_maybe basename) in
131+
let dir = Filename.dirname name_sans_extension in
132+
Map_string.adjust
133+
map
134+
module_name
135+
(fun opt_module_info ->
136+
match opt_module_info with
137+
| None ->
138+
{dir ; name_sans_extension ; info ; syntax_kind ; case }
139+
| Some x ->
140+
check x name_sans_extension case syntax_kind info
141+
)
142+
end

0 commit comments

Comments
 (0)