Skip to content

Commit 6941225

Browse files
Merge branch '11.0_release' into update-warning-numbers-info
2 parents 8a522c0 + ebfde30 commit 6941225

37 files changed

+121
-163
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,20 @@
1010
> - :house: [Internal]
1111
> - :nail_care: [Polish]
1212
13-
# 11.1.0-rc.4 (Unreleased)
13+
# 11.1.0-rc.5 (Unreleased)
14+
15+
# 11.1.0-rc.4
16+
17+
#### :bug: Bug Fix
18+
19+
- Fix emitting static import instead of dynamic import. https://github.com/rescript-lang/rescript-compiler/pull/6664
20+
- Fix local type variables breaking react components. https://github.com/rescript-lang/rescript-compiler/pull/6665
21+
- Fix remove redundant branches in generated switch body. https://github.com/rescript-lang/rescript-compiler/pull/6672
1422

1523
#### :nail-care: Polish
24+
1625
- Omit `undefined` in external function calls for trailing optional arguments when not supplied. https://github.com/rescript-lang/rescript-compiler/pull/6653
26+
- Make pattern match suggestions to be easier to copy-paste. https://github.com/rescript-lang/rescript-compiler/pull/6656
1727

1828
# 11.1.0-rc.3
1929

jscomp/build_tests/super_errors/expected/warnings4.res.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
14 │
1111

1212
You forgot to handle a possible case here, for example:
13-
#second(_) | #fourth | #third
13+
| #second(_) | #fourth | #third

jscomp/build_tests/super_errors/expected/warnings5.res.expected

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Either bind these labels explicitly or add ', _' to the pattern.
2424
15 │ switch y {
2525

2626
You forgot to handle a possible case here, for example:
27-
{otherValue: true, _}
27+
| {otherValue: true, _}
2828

2929

3030
Warning number 9
@@ -52,7 +52,7 @@ Either bind these labels explicitly or add ', _' to the pattern.
5252
19 │ let arr = [1]
5353

5454
You forgot to handle a possible case here, for example:
55-
{typ: WithPayload(false), _}
55+
| {typ: WithPayload(false), _}
5656
| {typ: Variant | One | Two | Three | Four | Five | Six | Seven(_), _}
5757

5858

@@ -68,7 +68,7 @@ Either bind these labels explicitly or add ', _' to the pattern.
6868
25 │ switch arr {
6969

7070
You forgot to handle a possible case here, for example:
71-
[_]
71+
| [_]
7272

7373

7474
Warning number 8
@@ -83,7 +83,7 @@ Either bind these labels explicitly or add ', _' to the pattern.
8383
29 │ switch arr {
8484

8585
You forgot to handle a possible case here, for example:
86-
[]
86+
| []
8787

8888

8989
Warning number 8
@@ -98,7 +98,7 @@ Either bind these labels explicitly or add ', _' to the pattern.
9898
33 │ let lst = list{}
9999

100100
You forgot to handle a possible case here, for example:
101-
[1, 0] | [0, _] | []
101+
| [1, 0] | [0, _] | []
102102

103103

104104
Warning number 8
@@ -113,7 +113,7 @@ Either bind these labels explicitly or add ', _' to the pattern.
113113
39 │ switch lst {
114114

115115
You forgot to handle a possible case here, for example:
116-
list{_, ..._}
116+
| list{_, ..._}
117117

118118

119119
Warning number 8
@@ -128,7 +128,7 @@ Either bind these labels explicitly or add ', _' to the pattern.
128128
43 │ switch lst {
129129

130130
You forgot to handle a possible case here, for example:
131-
list{1, 2, _, ..._} | list{1, 0, ..._} | list{1} | list{0, ..._} | list{}
131+
| list{1, 2, _, ..._} | list{1, 0, ..._} | list{1} | list{0, ..._} | list{}
132132

133133

134134
Warning number 8
@@ -143,7 +143,7 @@ Either bind these labels explicitly or add ', _' to the pattern.
143143
47 │ switch "abc" {
144144

145145
You forgot to handle a possible case here, for example:
146-
list{1, _, ..._} | list{0, ..._} | list{}
146+
| list{1, _, ..._} | list{0, ..._} | list{}
147147

148148

149149
Warning number 8
@@ -158,7 +158,7 @@ Either bind these labels explicitly or add ', _' to the pattern.
158158
51 │ switch 0 {
159159

160160
You forgot to handle a possible case here, for example:
161-
"*"
161+
| "*"
162162

163163

164164
Warning number 8
@@ -173,7 +173,7 @@ Either bind these labels explicitly or add ', _' to the pattern.
173173
55 │ let tuple = (1, true)
174174

175175
You forgot to handle a possible case here, for example:
176-
0
176+
| 0
177177

178178

179179
Warning number 8
@@ -187,4 +187,4 @@ Either bind these labels explicitly or add ', _' to the pattern.
187187
60 │
188188

189189
You forgot to handle a possible case here, for example:
190-
(_, true)
190+
| (_, true)

jscomp/common/bs_version.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
* You should have received a copy of the GNU Lesser General Public License
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
24-
let version = "11.1.0-rc.4"
24+
let version = "11.1.0-rc.5"
2525
let header = "// Generated by ReScript, PLEASE EDIT WITH CARE"
2626
let package_name = ref "rescript"

jscomp/core/lam.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -788,13 +788,13 @@ let rec transform_uncurried_arg_type loc (arg_types : External_arg_spec.params)
788788
| ([], [] | _ :: _, [] | [], _ :: _) as ok -> ok
789789

790790
let handle_bs_non_obj_ffi (arg_types : External_arg_spec.params)
791-
(result_type : External_ffi_types.return_wrapper) ffi args loc prim_name =
791+
(result_type : External_ffi_types.return_wrapper) ffi args loc prim_name ~dynamic_import =
792792
if no_auto_uncurried_arg_types arg_types then
793793
result_wrap loc result_type
794-
(prim ~primitive:(Pjs_call { prim_name; arg_types; ffi }) ~args loc)
794+
(prim ~primitive:(Pjs_call { prim_name; arg_types; ffi; dynamic_import }) ~args loc)
795795
else
796796
let n_arg_types, n_args = transform_uncurried_arg_type loc arg_types args in
797797
result_wrap loc result_type
798798
(prim
799-
~primitive:(Pjs_call { prim_name; arg_types = n_arg_types; ffi })
799+
~primitive:(Pjs_call { prim_name; arg_types = n_arg_types; ffi; dynamic_import })
800800
~args:n_args loc)

jscomp/core/lam.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ val handle_bs_non_obj_ffi :
9191
t list ->
9292
Location.t ->
9393
string ->
94+
dynamic_import: bool ->
9495
t
9596

9697
(**************************************************************)

jscomp/core/lam_compile.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,11 @@ and compile_general_cases :
573573
break still should not be printed (it will be continuned)
574574
TOOD: disabled temporarily since it's not perfect yet *)
575575
morph_declare_to_assign cxt (fun cxt declaration ->
576+
(* Exclude cases that are the same as the default if the default is defined *)
577+
let cases = match default with
578+
| Default lam -> List.filter (fun (_, lam1) -> not (Lam.eq_approx lam lam1)) cases
579+
| _ -> cases
580+
in
576581
let default =
577582
match default with
578583
| Complete -> None

jscomp/core/lam_compile_env.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ let reset () =
6060
be escaped quite ugly
6161
*)
6262
let add_js_module ?import_attributes (hint_name : External_ffi_types.module_bind_name)
63-
(module_name : string) default : Ident.t =
63+
(module_name : string) default ~dynamic_import : Ident.t =
6464
let id =
6565
Ident.create
6666
(match hint_name with
@@ -71,7 +71,7 @@ let add_js_module ?import_attributes (hint_name : External_ffi_types.module_bind
7171
| Phint_nothing -> Ext_modulename.js_id_name_of_hint_name module_name)
7272
in
7373
let lam_module_ident : J.module_id =
74-
{ id; kind = External { name = module_name; default; import_attributes }; dynamic_import = false }
74+
{ id; kind = External { name = module_name; default; import_attributes }; dynamic_import }
7575
in
7676
match Lam_module_ident.Hash.find_key_opt cached_tbl lam_module_ident with
7777
| None ->

jscomp/core/lam_compile_env.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
val reset : unit -> unit
2828

2929
val add_js_module :
30-
?import_attributes:External_ffi_types.import_attributes -> External_ffi_types.module_bind_name -> string -> bool -> Ident.t
30+
?import_attributes:External_ffi_types.import_attributes -> External_ffi_types.module_bind_name -> string -> bool -> dynamic_import:bool -> Ident.t
3131
(**
3232
[add_js_module hint_name module_name]
3333
Given a js module name and hint name, assign an id to it

jscomp/core/lam_compile_external_call.ml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ let splice_obj_apply obj name args =
5050
bundle *)
5151

5252
let external_var
53-
({ bundle; module_bind_name; import_attributes } : External_ffi_types.external_module_name) =
54-
let id = Lam_compile_env.add_js_module ?import_attributes module_bind_name bundle false in
53+
({ bundle; module_bind_name; import_attributes } : External_ffi_types.external_module_name) ~dynamic_import =
54+
let id = Lam_compile_env.add_js_module ?import_attributes module_bind_name bundle false ~dynamic_import in
5555
E.external_var ?import_attributes ~external_name:bundle id
5656

5757
(* let handle_external_opt
@@ -216,21 +216,22 @@ let assemble_args_has_splice (arg_types : specs) (args : exprs) :
216216

217217
let translate_scoped_module_val
218218
(module_name : External_ffi_types.external_module_name option) (fn : string)
219-
(scopes : string list) =
219+
(scopes : string list)
220+
~dynamic_import =
220221
match module_name with
221222
| Some { bundle; module_bind_name; import_attributes } -> (
222223
match scopes with
223224
| [] ->
224225
let default = fn = "default" in
225226
let id =
226-
Lam_compile_env.add_js_module ?import_attributes module_bind_name bundle default
227+
Lam_compile_env.add_js_module ?import_attributes module_bind_name bundle default ~dynamic_import
227228
in
228229
E.external_var_field ?import_attributes ~external_name:bundle ~field:fn ~default id
229230
| x :: rest ->
230231
(* TODO: what happens when scope contains "default" ?*)
231232
let default = false in
232233
let id =
233-
Lam_compile_env.add_js_module ?import_attributes module_bind_name bundle default
234+
Lam_compile_env.add_js_module ?import_attributes module_bind_name bundle default ~dynamic_import
234235
in
235236
let start =
236237
E.external_var_field ?import_attributes ~external_name:bundle ~field:x ~default id
@@ -250,10 +251,10 @@ let translate_scoped_access scopes obj =
250251
| x :: xs -> Ext_list.fold_left xs (E.dot obj x) E.dot
251252

252253
let translate_ffi (cxt : Lam_compile_context.t) arg_types
253-
(ffi : External_ffi_types.external_spec) (args : J.expression list) =
254+
(ffi : External_ffi_types.external_spec) (args : J.expression list) ~dynamic_import =
254255
match ffi with
255256
| Js_call { external_module_name; name; splice: _; scopes; tagged_template = true } ->
256-
let fn = translate_scoped_module_val external_module_name name scopes in
257+
let fn = translate_scoped_module_val external_module_name name scopes ~dynamic_import in
257258
(match args with
258259
| [ {expression_desc = Array (strings, _); _}; {expression_desc = Array (values, _); _} ] ->
259260
E.tagged_template fn strings values
@@ -262,7 +263,7 @@ let translate_ffi (cxt : Lam_compile_context.t) arg_types
262263
(if dynamic then splice_apply fn args
263264
else E.call ~info:{ arity = Full; call_info = Call_na } fn args))
264265
| Js_call { external_module_name = module_name; name = fn; splice; scopes; tagged_template = false } ->
265-
let fn = translate_scoped_module_val module_name fn scopes in
266+
let fn = translate_scoped_module_val module_name fn scopes ~dynamic_import in
266267
if splice then
267268
let args, eff, dynamic = assemble_args_has_splice arg_types args in
268269
add_eff eff
@@ -283,7 +284,7 @@ let translate_ffi (cxt : Lam_compile_context.t) arg_types
283284
add_eff eff
284285
@@ E.call ~info:{ arity = Full; call_info = Call_na } fn args
285286
| Js_module_as_fn { external_module_name; splice } ->
286-
let fn = external_var external_module_name in
287+
let fn = external_var external_module_name ~dynamic_import in
287288
if splice then
288289
let args, eff, dynamic = assemble_args_has_splice arg_types args in
289290
(* TODO: fix in rest calling convention *)
@@ -313,14 +314,14 @@ let translate_ffi (cxt : Lam_compile_context.t) arg_types
313314
in
314315
if splice then
315316
let args, eff, dynamic = assemble_args_has_splice arg_types args in
316-
let fn = translate_scoped_module_val module_name fn scopes in
317+
let fn = translate_scoped_module_val module_name fn scopes ~dynamic_import in
317318
add_eff eff
318319
(mark ();
319320
if dynamic then splice_new_apply fn args
320321
else E.new_ fn args)
321322
else
322323
let args, eff = assemble_args_no_splice arg_types args in
323-
let fn = translate_scoped_module_val module_name fn scopes in
324+
let fn = translate_scoped_module_val module_name fn scopes ~dynamic_import in
324325
add_eff eff
325326
(mark (); E.new_ fn args)
326327
| Js_send { splice; name; js_send_scopes } -> (
@@ -346,16 +347,16 @@ let translate_ffi (cxt : Lam_compile_context.t) arg_types
346347
~info:{ arity = Full; call_info = Call_na }
347348
(E.dot self name) args)
348349
| _ -> assert false)
349-
| Js_module_as_var module_name -> external_var module_name
350+
| Js_module_as_var module_name -> external_var module_name ~dynamic_import
350351
| Js_var { name; external_module_name; scopes } ->
351352
(* TODO #11
352353
1. check args -- error checking
353354
2. support [@@scope "window"]
354355
we need know whether we should call [add_js_module] or not
355356
*)
356-
translate_scoped_module_val external_module_name name scopes
357+
translate_scoped_module_val external_module_name name scopes ~dynamic_import
357358
| Js_module_as_class module_name ->
358-
let fn = external_var module_name in
359+
let fn = external_var module_name ~dynamic_import in
359360
let args, eff = assemble_args_no_splice arg_types args in
360361
(* TODO: fix in rest calling convention *)
361362
add_eff eff

0 commit comments

Comments
 (0)