Skip to content

Sync latest syntax. #5751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

# 10.1.0-rc.3

- Fix issue where the JSX key type is not an optional string https://github.com/rescript-lang/syntax/pull/693

# 10.1.0-rc.2

#### :bug: Bug Fix
Expand Down
1 change: 1 addition & 0 deletions jscomp/napkin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
- Fix several printing issues with `async` including an infinite loop https://github.com/rescript-lang/syntax/pull/680
- Fix issue where certain JSX expressions would be formatted differenctly in compiler 10.1.0-rc.1 https://github.com/rescript-lang/syntax/issues/675
- Fix issue where printing nested pipe discards await https://github.com/rescript-lang/syntax/issues/687
- Fix issue where the JSX key type is not an optional string https://github.com/rescript-lang/syntax/pull/693

#### :eyeglasses: Spec Compliance

Expand Down
39 changes: 18 additions & 21 deletions lib/4.06.1/unstable/js_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -273011,6 +273011,8 @@ let constantString ~loc str =
(* {} empty record *)
let emptyRecord ~loc = Exp.record ~loc [] None

let unitExpr ~loc = Exp.construct ~loc (Location.mkloc (Lident "()") loc) None

let safeTypeFromValue valueStr =
let valueStr = getLabel valueStr in
if valueStr = "" || (valueStr.[0] [@doesNotRaise]) <> '_' then valueStr
Expand Down Expand Up @@ -273360,51 +273362,46 @@ let transformUppercaseCall3 ~config modulePath mapper jsxExprLoc callExprLoc
match config.mode with
(* The new jsx transform *)
| "automatic" ->
let jsxExpr, key =
let jsxExpr, keyAndUnit =
match (!childrenArg, keyProp) with
| None, (_, keyExpr) :: _ ->
| None, key :: _ ->
( Exp.ident
{loc = Location.none; txt = Ldot (Lident "React", "jsxKeyed")},
[(nolabel, keyExpr)] )
[key; (nolabel, unitExpr ~loc:Location.none)] )
| None, [] ->
(Exp.ident {loc = Location.none; txt = Ldot (Lident "React", "jsx")}, [])
| Some _, (_, keyExpr) :: _ ->
| Some _, key :: _ ->
( Exp.ident
{loc = Location.none; txt = Ldot (Lident "React", "jsxsKeyed")},
[(nolabel, keyExpr)] )
[key; (nolabel, unitExpr ~loc:Location.none)] )
| Some _, [] ->
( Exp.ident {loc = Location.none; txt = Ldot (Lident "React", "jsxs")},
[] )
in
Exp.apply ~attrs jsxExpr ([(nolabel, makeID); (nolabel, props)] @ key)
Exp.apply ~attrs jsxExpr ([(nolabel, makeID); (nolabel, props)] @ keyAndUnit)
| _ -> (
match (!childrenArg, keyProp) with
| None, (_, keyExpr) :: _ ->
| None, key :: _ ->
Exp.apply ~attrs
(Exp.ident
{
loc = Location.none;
txt = Ldot (Lident "React", "createElementWithKey");
})
[(nolabel, makeID); (nolabel, props); (nolabel, keyExpr)]
[key; (nolabel, makeID); (nolabel, props)]
| None, [] ->
Exp.apply ~attrs
(Exp.ident
{loc = Location.none; txt = Ldot (Lident "React", "createElement")})
[(nolabel, makeID); (nolabel, props)]
| Some children, (_, keyExpr) :: _ ->
| Some children, key :: _ ->
Exp.apply ~attrs
(Exp.ident
{
loc = Location.none;
txt = Ldot (Lident "React", "createElementVariadicWithKey");
})
[
(nolabel, makeID);
(nolabel, props);
(nolabel, children);
(nolabel, keyExpr);
]
[key; (nolabel, makeID); (nolabel, props); (nolabel, children)]
| Some children, [] ->
Exp.apply ~attrs
(Exp.ident
Expand Down Expand Up @@ -273470,25 +273467,25 @@ let transformLowercaseCall3 ~config mapper jsxExprLoc callExprLoc attrs
let keyProp =
args |> List.filter (fun (arg_label, _) -> "key" = getLabel arg_label)
in
let jsxExpr, key =
let jsxExpr, keyAndUnit =
match (!childrenArg, keyProp) with
| None, (_, keyExpr) :: _ ->
| None, key :: _ ->
( Exp.ident
{loc = Location.none; txt = Ldot (Lident "ReactDOM", "jsxKeyed")},
[(nolabel, keyExpr)] )
[key; (nolabel, unitExpr ~loc:Location.none)] )
| None, [] ->
( Exp.ident {loc = Location.none; txt = Ldot (Lident "ReactDOM", "jsx")},
[] )
| Some _, (_, keyExpr) :: _ ->
| Some _, key :: _ ->
( Exp.ident
{loc = Location.none; txt = Ldot (Lident "ReactDOM", "jsxsKeyed")},
[(nolabel, keyExpr)] )
[key; (nolabel, unitExpr ~loc:Location.none)] )
| Some _, [] ->
( Exp.ident {loc = Location.none; txt = Ldot (Lident "ReactDOM", "jsxs")},
[] )
in
Exp.apply ~attrs jsxExpr
([(nolabel, componentNameExpr); (nolabel, props)] @ key)
([(nolabel, componentNameExpr); (nolabel, props)] @ keyAndUnit)
| _ ->
let children, nonChildrenProps =
extractChildren ~loc:jsxExprLoc callArguments
Expand Down
39 changes: 18 additions & 21 deletions lib/4.06.1/unstable/js_playground_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -274474,6 +274474,8 @@ let constantString ~loc str =
(* {} empty record *)
let emptyRecord ~loc = Exp.record ~loc [] None

let unitExpr ~loc = Exp.construct ~loc (Location.mkloc (Lident "()") loc) None

let safeTypeFromValue valueStr =
let valueStr = getLabel valueStr in
if valueStr = "" || (valueStr.[0] [@doesNotRaise]) <> '_' then valueStr
Expand Down Expand Up @@ -274823,51 +274825,46 @@ let transformUppercaseCall3 ~config modulePath mapper jsxExprLoc callExprLoc
match config.mode with
(* The new jsx transform *)
| "automatic" ->
let jsxExpr, key =
let jsxExpr, keyAndUnit =
match (!childrenArg, keyProp) with
| None, (_, keyExpr) :: _ ->
| None, key :: _ ->
( Exp.ident
{loc = Location.none; txt = Ldot (Lident "React", "jsxKeyed")},
[(nolabel, keyExpr)] )
[key; (nolabel, unitExpr ~loc:Location.none)] )
| None, [] ->
(Exp.ident {loc = Location.none; txt = Ldot (Lident "React", "jsx")}, [])
| Some _, (_, keyExpr) :: _ ->
| Some _, key :: _ ->
( Exp.ident
{loc = Location.none; txt = Ldot (Lident "React", "jsxsKeyed")},
[(nolabel, keyExpr)] )
[key; (nolabel, unitExpr ~loc:Location.none)] )
| Some _, [] ->
( Exp.ident {loc = Location.none; txt = Ldot (Lident "React", "jsxs")},
[] )
in
Exp.apply ~attrs jsxExpr ([(nolabel, makeID); (nolabel, props)] @ key)
Exp.apply ~attrs jsxExpr ([(nolabel, makeID); (nolabel, props)] @ keyAndUnit)
| _ -> (
match (!childrenArg, keyProp) with
| None, (_, keyExpr) :: _ ->
| None, key :: _ ->
Exp.apply ~attrs
(Exp.ident
{
loc = Location.none;
txt = Ldot (Lident "React", "createElementWithKey");
})
[(nolabel, makeID); (nolabel, props); (nolabel, keyExpr)]
[key; (nolabel, makeID); (nolabel, props)]
| None, [] ->
Exp.apply ~attrs
(Exp.ident
{loc = Location.none; txt = Ldot (Lident "React", "createElement")})
[(nolabel, makeID); (nolabel, props)]
| Some children, (_, keyExpr) :: _ ->
| Some children, key :: _ ->
Exp.apply ~attrs
(Exp.ident
{
loc = Location.none;
txt = Ldot (Lident "React", "createElementVariadicWithKey");
})
[
(nolabel, makeID);
(nolabel, props);
(nolabel, children);
(nolabel, keyExpr);
]
[key; (nolabel, makeID); (nolabel, props); (nolabel, children)]
| Some children, [] ->
Exp.apply ~attrs
(Exp.ident
Expand Down Expand Up @@ -274933,25 +274930,25 @@ let transformLowercaseCall3 ~config mapper jsxExprLoc callExprLoc attrs
let keyProp =
args |> List.filter (fun (arg_label, _) -> "key" = getLabel arg_label)
in
let jsxExpr, key =
let jsxExpr, keyAndUnit =
match (!childrenArg, keyProp) with
| None, (_, keyExpr) :: _ ->
| None, key :: _ ->
( Exp.ident
{loc = Location.none; txt = Ldot (Lident "ReactDOM", "jsxKeyed")},
[(nolabel, keyExpr)] )
[key; (nolabel, unitExpr ~loc:Location.none)] )
| None, [] ->
( Exp.ident {loc = Location.none; txt = Ldot (Lident "ReactDOM", "jsx")},
[] )
| Some _, (_, keyExpr) :: _ ->
| Some _, key :: _ ->
( Exp.ident
{loc = Location.none; txt = Ldot (Lident "ReactDOM", "jsxsKeyed")},
[(nolabel, keyExpr)] )
[key; (nolabel, unitExpr ~loc:Location.none)] )
| Some _, [] ->
( Exp.ident {loc = Location.none; txt = Ldot (Lident "ReactDOM", "jsxs")},
[] )
in
Exp.apply ~attrs jsxExpr
([(nolabel, componentNameExpr); (nolabel, props)] @ key)
([(nolabel, componentNameExpr); (nolabel, props)] @ keyAndUnit)
| _ ->
let children, nonChildrenProps =
extractChildren ~loc:jsxExprLoc callArguments
Expand Down
39 changes: 18 additions & 21 deletions lib/4.06.1/whole_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -284858,6 +284858,8 @@ let constantString ~loc str =
(* {} empty record *)
let emptyRecord ~loc = Exp.record ~loc [] None

let unitExpr ~loc = Exp.construct ~loc (Location.mkloc (Lident "()") loc) None

let safeTypeFromValue valueStr =
let valueStr = getLabel valueStr in
if valueStr = "" || (valueStr.[0] [@doesNotRaise]) <> '_' then valueStr
Expand Down Expand Up @@ -285207,51 +285209,46 @@ let transformUppercaseCall3 ~config modulePath mapper jsxExprLoc callExprLoc
match config.mode with
(* The new jsx transform *)
| "automatic" ->
let jsxExpr, key =
let jsxExpr, keyAndUnit =
match (!childrenArg, keyProp) with
| None, (_, keyExpr) :: _ ->
| None, key :: _ ->
( Exp.ident
{loc = Location.none; txt = Ldot (Lident "React", "jsxKeyed")},
[(nolabel, keyExpr)] )
[key; (nolabel, unitExpr ~loc:Location.none)] )
| None, [] ->
(Exp.ident {loc = Location.none; txt = Ldot (Lident "React", "jsx")}, [])
| Some _, (_, keyExpr) :: _ ->
| Some _, key :: _ ->
( Exp.ident
{loc = Location.none; txt = Ldot (Lident "React", "jsxsKeyed")},
[(nolabel, keyExpr)] )
[key; (nolabel, unitExpr ~loc:Location.none)] )
| Some _, [] ->
( Exp.ident {loc = Location.none; txt = Ldot (Lident "React", "jsxs")},
[] )
in
Exp.apply ~attrs jsxExpr ([(nolabel, makeID); (nolabel, props)] @ key)
Exp.apply ~attrs jsxExpr ([(nolabel, makeID); (nolabel, props)] @ keyAndUnit)
| _ -> (
match (!childrenArg, keyProp) with
| None, (_, keyExpr) :: _ ->
| None, key :: _ ->
Exp.apply ~attrs
(Exp.ident
{
loc = Location.none;
txt = Ldot (Lident "React", "createElementWithKey");
})
[(nolabel, makeID); (nolabel, props); (nolabel, keyExpr)]
[key; (nolabel, makeID); (nolabel, props)]
| None, [] ->
Exp.apply ~attrs
(Exp.ident
{loc = Location.none; txt = Ldot (Lident "React", "createElement")})
[(nolabel, makeID); (nolabel, props)]
| Some children, (_, keyExpr) :: _ ->
| Some children, key :: _ ->
Exp.apply ~attrs
(Exp.ident
{
loc = Location.none;
txt = Ldot (Lident "React", "createElementVariadicWithKey");
})
[
(nolabel, makeID);
(nolabel, props);
(nolabel, children);
(nolabel, keyExpr);
]
[key; (nolabel, makeID); (nolabel, props); (nolabel, children)]
| Some children, [] ->
Exp.apply ~attrs
(Exp.ident
Expand Down Expand Up @@ -285317,25 +285314,25 @@ let transformLowercaseCall3 ~config mapper jsxExprLoc callExprLoc attrs
let keyProp =
args |> List.filter (fun (arg_label, _) -> "key" = getLabel arg_label)
in
let jsxExpr, key =
let jsxExpr, keyAndUnit =
match (!childrenArg, keyProp) with
| None, (_, keyExpr) :: _ ->
| None, key :: _ ->
( Exp.ident
{loc = Location.none; txt = Ldot (Lident "ReactDOM", "jsxKeyed")},
[(nolabel, keyExpr)] )
[key; (nolabel, unitExpr ~loc:Location.none)] )
| None, [] ->
( Exp.ident {loc = Location.none; txt = Ldot (Lident "ReactDOM", "jsx")},
[] )
| Some _, (_, keyExpr) :: _ ->
| Some _, key :: _ ->
( Exp.ident
{loc = Location.none; txt = Ldot (Lident "ReactDOM", "jsxsKeyed")},
[(nolabel, keyExpr)] )
[key; (nolabel, unitExpr ~loc:Location.none)] )
| Some _, [] ->
( Exp.ident {loc = Location.none; txt = Ldot (Lident "ReactDOM", "jsxs")},
[] )
in
Exp.apply ~attrs jsxExpr
([(nolabel, componentNameExpr); (nolabel, props)] @ key)
([(nolabel, componentNameExpr); (nolabel, props)] @ keyAndUnit)
| _ ->
let children, nonChildrenProps =
extractChildren ~loc:jsxExprLoc callArguments
Expand Down