Skip to content

Commit 24d51fa

Browse files
committed
Latest syntax: use empty record in JSX V4.
1 parent 1649bf1 commit 24d51fa

File tree

4 files changed

+19
-49
lines changed

4 files changed

+19
-49
lines changed

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -272936,15 +272936,8 @@ module V4 = struct
272936272936
let constantString ~loc str =
272937272937
Ast_helper.Exp.constant ~loc (Pconst_string (str, None))
272938272938

272939-
(* {} empty object in Js *)
272940-
let recordWithOnlyKey ~loc =
272941-
Exp.record ~loc
272942-
(* {key: @optional None} *)
272943-
[
272944-
( {loc; txt = Lident "key"},
272945-
Exp.construct ~attrs:optionalAttr {loc; txt = Lident "None"} None );
272946-
]
272947-
None
272939+
(* {} empty record *)
272940+
let emptyRecord ~loc = Exp.record ~loc [] None
272948272941

272949272942
let safeTypeFromValue valueStr =
272950272943
let valueStr = getLabel valueStr in
@@ -273273,8 +273266,7 @@ module V4 = struct
273273273266
| "automatic" ->
273274273267
let record = recordFromProps ~loc:jsxExprLoc ~removeKey:true args in
273275273268
let props =
273276-
if isEmptyRecord record then recordWithOnlyKey ~loc:jsxExprLoc
273277-
else record
273269+
if isEmptyRecord record then emptyRecord ~loc:jsxExprLoc else record
273278273270
in
273279273271
let keyProp =
273280273272
args |> List.filter (fun (arg_label, _) -> "key" = getLabel arg_label)
@@ -273309,8 +273301,7 @@ module V4 = struct
273309273301
This would be redundant regarding PR progress https://github.com/rescript-lang/syntax/pull/299
273310273302
*)
273311273303
let props =
273312-
if isEmptyRecord record then recordWithOnlyKey ~loc:jsxExprLoc
273313-
else record
273304+
if isEmptyRecord record then emptyRecord ~loc:jsxExprLoc else record
273314273305
in
273315273306
match !childrenArg with
273316273307
| None ->
@@ -273377,8 +273368,7 @@ module V4 = struct
273377273368
in
273378273369
let record = recordFromProps ~loc:jsxExprLoc ~removeKey:true args in
273379273370
let props =
273380-
if isEmptyRecord record then recordWithOnlyKey ~loc:jsxExprLoc
273381-
else record
273371+
if isEmptyRecord record then emptyRecord ~loc:jsxExprLoc else record
273382273372
in
273383273373
let keyProp =
273384273374
args |> List.filter (fun (arg_label, _) -> "key" = getLabel arg_label)
@@ -274224,7 +274214,7 @@ module V4 = struct
274224274214
match childrenExpr with
274225274215
| {pexp_desc = Pexp_array children} -> (
274226274216
match children with
274227-
| [] -> recordWithOnlyKey ~loc:Location.none
274217+
| [] -> emptyRecord ~loc:Location.none
274228274218
| [child] -> child
274229274219
| _ -> childrenExpr)
274230274220
| _ -> childrenExpr );

lib/4.06.1/unstable/js_playground_compiler.ml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -274399,15 +274399,8 @@ module V4 = struct
274399274399
let constantString ~loc str =
274400274400
Ast_helper.Exp.constant ~loc (Pconst_string (str, None))
274401274401

274402-
(* {} empty object in Js *)
274403-
let recordWithOnlyKey ~loc =
274404-
Exp.record ~loc
274405-
(* {key: @optional None} *)
274406-
[
274407-
( {loc; txt = Lident "key"},
274408-
Exp.construct ~attrs:optionalAttr {loc; txt = Lident "None"} None );
274409-
]
274410-
None
274402+
(* {} empty record *)
274403+
let emptyRecord ~loc = Exp.record ~loc [] None
274411274404

274412274405
let safeTypeFromValue valueStr =
274413274406
let valueStr = getLabel valueStr in
@@ -274736,8 +274729,7 @@ module V4 = struct
274736274729
| "automatic" ->
274737274730
let record = recordFromProps ~loc:jsxExprLoc ~removeKey:true args in
274738274731
let props =
274739-
if isEmptyRecord record then recordWithOnlyKey ~loc:jsxExprLoc
274740-
else record
274732+
if isEmptyRecord record then emptyRecord ~loc:jsxExprLoc else record
274741274733
in
274742274734
let keyProp =
274743274735
args |> List.filter (fun (arg_label, _) -> "key" = getLabel arg_label)
@@ -274772,8 +274764,7 @@ module V4 = struct
274772274764
This would be redundant regarding PR progress https://github.com/rescript-lang/syntax/pull/299
274773274765
*)
274774274766
let props =
274775-
if isEmptyRecord record then recordWithOnlyKey ~loc:jsxExprLoc
274776-
else record
274767+
if isEmptyRecord record then emptyRecord ~loc:jsxExprLoc else record
274777274768
in
274778274769
match !childrenArg with
274779274770
| None ->
@@ -274840,8 +274831,7 @@ module V4 = struct
274840274831
in
274841274832
let record = recordFromProps ~loc:jsxExprLoc ~removeKey:true args in
274842274833
let props =
274843-
if isEmptyRecord record then recordWithOnlyKey ~loc:jsxExprLoc
274844-
else record
274834+
if isEmptyRecord record then emptyRecord ~loc:jsxExprLoc else record
274845274835
in
274846274836
let keyProp =
274847274837
args |> List.filter (fun (arg_label, _) -> "key" = getLabel arg_label)
@@ -275687,7 +275677,7 @@ module V4 = struct
275687275677
match childrenExpr with
275688275678
| {pexp_desc = Pexp_array children} -> (
275689275679
match children with
275690-
| [] -> recordWithOnlyKey ~loc:Location.none
275680+
| [] -> emptyRecord ~loc:Location.none
275691275681
| [child] -> child
275692275682
| _ -> childrenExpr)
275693275683
| _ -> childrenExpr );

lib/4.06.1/whole_compiler.ml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -284778,15 +284778,8 @@ module V4 = struct
284778284778
let constantString ~loc str =
284779284779
Ast_helper.Exp.constant ~loc (Pconst_string (str, None))
284780284780

284781-
(* {} empty object in Js *)
284782-
let recordWithOnlyKey ~loc =
284783-
Exp.record ~loc
284784-
(* {key: @optional None} *)
284785-
[
284786-
( {loc; txt = Lident "key"},
284787-
Exp.construct ~attrs:optionalAttr {loc; txt = Lident "None"} None );
284788-
]
284789-
None
284781+
(* {} empty record *)
284782+
let emptyRecord ~loc = Exp.record ~loc [] None
284790284783

284791284784
let safeTypeFromValue valueStr =
284792284785
let valueStr = getLabel valueStr in
@@ -285115,8 +285108,7 @@ module V4 = struct
285115285108
| "automatic" ->
285116285109
let record = recordFromProps ~loc:jsxExprLoc ~removeKey:true args in
285117285110
let props =
285118-
if isEmptyRecord record then recordWithOnlyKey ~loc:jsxExprLoc
285119-
else record
285111+
if isEmptyRecord record then emptyRecord ~loc:jsxExprLoc else record
285120285112
in
285121285113
let keyProp =
285122285114
args |> List.filter (fun (arg_label, _) -> "key" = getLabel arg_label)
@@ -285151,8 +285143,7 @@ module V4 = struct
285151285143
This would be redundant regarding PR progress https://github.com/rescript-lang/syntax/pull/299
285152285144
*)
285153285145
let props =
285154-
if isEmptyRecord record then recordWithOnlyKey ~loc:jsxExprLoc
285155-
else record
285146+
if isEmptyRecord record then emptyRecord ~loc:jsxExprLoc else record
285156285147
in
285157285148
match !childrenArg with
285158285149
| None ->
@@ -285219,8 +285210,7 @@ module V4 = struct
285219285210
in
285220285211
let record = recordFromProps ~loc:jsxExprLoc ~removeKey:true args in
285221285212
let props =
285222-
if isEmptyRecord record then recordWithOnlyKey ~loc:jsxExprLoc
285223-
else record
285213+
if isEmptyRecord record then emptyRecord ~loc:jsxExprLoc else record
285224285214
in
285225285215
let keyProp =
285226285216
args |> List.filter (fun (arg_label, _) -> "key" = getLabel arg_label)
@@ -286066,7 +286056,7 @@ module V4 = struct
286066286056
match childrenExpr with
286067286057
| {pexp_desc = Pexp_array children} -> (
286068286058
match children with
286069-
| [] -> recordWithOnlyKey ~loc:Location.none
286059+
| [] -> emptyRecord ~loc:Location.none
286070286060
| [child] -> child
286071286061
| _ -> childrenExpr)
286072286062
| _ -> childrenExpr );

0 commit comments

Comments
 (0)