From 89c17bad0f2a0e9cbb5de5ddb67b4e9232284d3f Mon Sep 17 00:00:00 2001 From: Woonki Moon Date: Wed, 14 Sep 2022 15:01:41 +0900 Subject: [PATCH 1/3] add loc for returned component body --- cli/reactjs_jsx_ppx.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/reactjs_jsx_ppx.ml b/cli/reactjs_jsx_ppx.ml index 018d9546..0ae2708b 100644 --- a/cli/reactjs_jsx_ppx.ml +++ b/cli/reactjs_jsx_ppx.ml @@ -2331,7 +2331,7 @@ module V4 = struct (Pat.var ~loc:emptyLoc {loc = emptyLoc; txt}) fullExpression; ] - (Exp.ident ~loc:emptyLoc {loc = emptyLoc; txt = Lident txt}) + (Exp.ident ~loc:pstr_loc {loc = emptyLoc; txt = Lident txt}) in let stripConstraint pattern = match pattern with From 9716cbb4005a696ba51caa0eb97d083cdff375f5 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Wed, 14 Sep 2022 09:39:52 +0200 Subject: [PATCH 2/3] Check in modified tests. --- tests/ppx/react/expected/commentAtTop.res.txt | 1 + tests/ppx/react/expected/fileLevelConfig.res.txt | 2 ++ tests/ppx/react/expected/forwardRef.res.txt | 4 ++++ tests/ppx/react/expected/newtype.res.txt | 2 ++ tests/ppx/react/expected/topLevel.res.txt | 2 ++ tests/ppx/react/expected/typeConstraint.res.txt | 2 ++ tests/ppx/react/expected/v4.res.txt | 1 + 7 files changed, 14 insertions(+) diff --git a/tests/ppx/react/expected/commentAtTop.res.txt b/tests/ppx/react/expected/commentAtTop.res.txt index 2367e3d0..290974f3 100644 --- a/tests/ppx/react/expected/commentAtTop.res.txt +++ b/tests/ppx/react/expected/commentAtTop.res.txt @@ -6,5 +6,6 @@ let make = ({msg, _}: props<'msg>) => { } let make = { let \"CommentAtTop" = (props: props<_>) => make(props) + \"CommentAtTop" } diff --git a/tests/ppx/react/expected/fileLevelConfig.res.txt b/tests/ppx/react/expected/fileLevelConfig.res.txt index b208f661..ecfa665e 100644 --- a/tests/ppx/react/expected/fileLevelConfig.res.txt +++ b/tests/ppx/react/expected/fileLevelConfig.res.txt @@ -25,6 +25,7 @@ module V4C = { } let make = { let \"FileLevelConfig$V4C" = (props: props<_>) => make(props) + \"FileLevelConfig$V4C" } } @@ -40,6 +41,7 @@ module V4A = { } let make = { let \"FileLevelConfig$V4A" = (props: props<_>) => make(props) + \"FileLevelConfig$V4A" } } diff --git a/tests/ppx/react/expected/forwardRef.res.txt b/tests/ppx/react/expected/forwardRef.res.txt index b0804f13..13d0a16d 100644 --- a/tests/ppx/react/expected/forwardRef.res.txt +++ b/tests/ppx/react/expected/forwardRef.res.txt @@ -93,6 +93,7 @@ module V4C = { ) let make = React.forwardRef({ let \"ForwardRef$V4C$FancyInput" = (props: props<_>, ref) => make(props, ref) + \"ForwardRef$V4C$FancyInput" }) } @@ -114,6 +115,7 @@ module V4C = { } let make = { let \"ForwardRef$V4C" = props => make(props) + \"ForwardRef$V4C" } } @@ -149,6 +151,7 @@ module V4A = { ) let make = React.forwardRef({ let \"ForwardRef$V4A$FancyInput" = (props: props<_>, ref) => make(props, ref) + \"ForwardRef$V4A$FancyInput" }) } @@ -169,6 +172,7 @@ module V4A = { } let make = { let \"ForwardRef$V4A" = props => make(props) + \"ForwardRef$V4A" } } diff --git a/tests/ppx/react/expected/newtype.res.txt b/tests/ppx/react/expected/newtype.res.txt index 8cb1718d..9d69a14e 100644 --- a/tests/ppx/react/expected/newtype.res.txt +++ b/tests/ppx/react/expected/newtype.res.txt @@ -31,6 +31,7 @@ module V4C = { ReactDOMRe.createDOMElementVariadic("div", []) let make = { let \"Newtype$V4C" = (props: props<_>) => make(props) + \"Newtype$V4C" } } @@ -45,6 +46,7 @@ module V4A = { ReactDOM.jsx("div", {key: ?None}) let make = { let \"Newtype$V4A" = (props: props<_>) => make(props) + \"Newtype$V4A" } } diff --git a/tests/ppx/react/expected/topLevel.res.txt b/tests/ppx/react/expected/topLevel.res.txt index 2cc8aed1..39dc6524 100644 --- a/tests/ppx/react/expected/topLevel.res.txt +++ b/tests/ppx/react/expected/topLevel.res.txt @@ -28,6 +28,7 @@ module V4C = { } let make = { let \"TopLevel$V4C" = (props: props<_>) => make(props) + \"TopLevel$V4C" } } @@ -44,6 +45,7 @@ module V4A = { } let make = { let \"TopLevel$V4A" = (props: props<_>) => make(props) + \"TopLevel$V4A" } } diff --git a/tests/ppx/react/expected/typeConstraint.res.txt b/tests/ppx/react/expected/typeConstraint.res.txt index 87968f21..26b0ec34 100644 --- a/tests/ppx/react/expected/typeConstraint.res.txt +++ b/tests/ppx/react/expected/typeConstraint.res.txt @@ -24,6 +24,7 @@ module V4C = { ReactDOMRe.createDOMElementVariadic("div", []) let make = { let \"TypeConstraint$V4C" = (props: props<_>) => make(props) + \"TypeConstraint$V4C" } } @@ -37,6 +38,7 @@ module V4A = { let make = ({a, b, _}: props<'\"type-a", '\"type-a">) => ReactDOM.jsx("div", {key: ?None}) let make = { let \"TypeConstraint$V4A" = (props: props<_>) => make(props) + \"TypeConstraint$V4A" } } diff --git a/tests/ppx/react/expected/v4.res.txt b/tests/ppx/react/expected/v4.res.txt index f85e9eef..7ac379e6 100644 --- a/tests/ppx/react/expected/v4.res.txt +++ b/tests/ppx/react/expected/v4.res.txt @@ -12,6 +12,7 @@ module AnotherName = { @react.component let anotherName = ({x, _}: props<'x>) => React.string(x) let anotherName = { let \"V4$AnotherName$anotherName" = (props: props<_>) => anotherName(props) + \"V4$AnotherName$anotherName" } } From ace65c9202ef7815c512608f990f37a76f92b09a Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Wed, 14 Sep 2022 09:41:10 +0200 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d885d754..2d2efd4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,10 +18,11 @@ - :boom: when V4 is activated, at most one component is allowed for each module. -- Add support for empty record literal `{}` for records with only optional fields, and type definition of empty record (e.g. `type empty = {}`) https://github.com/rescript-lang/syntax/pull/632 +- Add support for empty record literal `{}` for records with only optional fields, and type definition of empty record (e.g. `type empty = {}`) https://github.com/rescript-lang/syntax/pull/632 #### :bug: Bug Fix +- Fix location issue in error messages with JSX V4 where the body of the component is an application https://github.com/rescript-lang/syntax/pull/633 - Fix issue where the printer would omit attributes for `->` and `|>` https://github.com/rescript-lang/syntax/pull/629 - Fix printing of optional fields in records https://github.com/rescript-lang/rescript-compiler/issues/5654