From 4dedbbd66ff808c6d3a6cb40200eccbd5e3ffaa2 Mon Sep 17 00:00:00 2001 From: Woonki Moon Date: Sat, 28 Jan 2023 19:58:55 +0900 Subject: [PATCH 1/4] add missing loc of jsx call expression --- res_syntax/src/reactjs_jsx_v4.ml | 13 +++++++------ .../tests/ppx/react/expected/forwardRef.res.txt | 2 ++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/res_syntax/src/reactjs_jsx_v4.ml b/res_syntax/src/reactjs_jsx_v4.ml index a277f52075..7f21c7fa90 100644 --- a/res_syntax/src/reactjs_jsx_v4.ml +++ b/res_syntax/src/reactjs_jsx_v4.ml @@ -437,11 +437,12 @@ let transformUppercaseCall3 ~config modulePath mapper jsxExprLoc callExprLoc ( Exp.ident {loc = Location.none; txt = Ldot (Lident "React", "jsxs")}, [] ) in - Exp.apply ~attrs jsxExpr ([(nolabel, makeID); (nolabel, props)] @ keyAndUnit) + Exp.apply ~loc:jsxExprLoc ~attrs jsxExpr + ([(nolabel, makeID); (nolabel, props)] @ keyAndUnit) | _ -> ( match (!childrenArg, keyProp) with | None, key :: _ -> - Exp.apply ~attrs + Exp.apply ~loc:jsxExprLoc ~attrs (Exp.ident { loc = Location.none; @@ -449,12 +450,12 @@ let transformUppercaseCall3 ~config modulePath mapper jsxExprLoc callExprLoc }) [key; (nolabel, makeID); (nolabel, props)] | None, [] -> - Exp.apply ~attrs + Exp.apply ~loc:jsxExprLoc ~attrs (Exp.ident {loc = Location.none; txt = Ldot (Lident "React", "createElement")}) [(nolabel, makeID); (nolabel, props)] | Some children, key :: _ -> - Exp.apply ~attrs + Exp.apply ~loc:jsxExprLoc ~attrs (Exp.ident { loc = Location.none; @@ -463,7 +464,7 @@ let transformUppercaseCall3 ~config modulePath mapper jsxExprLoc callExprLoc }) [key; (nolabel, makeID); (nolabel, props); (nolabel, children)] | Some children, [] -> - Exp.apply ~attrs + Exp.apply ~loc:jsxExprLoc ~attrs (Exp.ident { loc = Location.none; @@ -544,7 +545,7 @@ let transformLowercaseCall3 ~config mapper jsxExprLoc callExprLoc attrs ( Exp.ident {loc = Location.none; txt = Ldot (Lident "ReactDOM", "jsxs")}, [] ) in - Exp.apply ~attrs jsxExpr + Exp.apply ~loc:jsxExprLoc ~attrs jsxExpr ([(nolabel, componentNameExpr); (nolabel, props)] @ keyAndUnit) | _ -> let children, nonChildrenProps = diff --git a/res_syntax/tests/ppx/react/expected/forwardRef.res.txt b/res_syntax/tests/ppx/react/expected/forwardRef.res.txt index c071e3c83b..815228c7f0 100644 --- a/res_syntax/tests/ppx/react/expected/forwardRef.res.txt +++ b/res_syntax/tests/ppx/react/expected/forwardRef.res.txt @@ -223,6 +223,7 @@ module V4A = { @react.component let make = (_: props) => { let input = React.useRef(Js.Nullable.null) + ReactDOM.jsx( "div", { @@ -279,6 +280,7 @@ module V4AUncurried = { @react.component let make = (_: props) => { let input = React.useRef(Js.Nullable.null) + ReactDOM.jsx( "div", { From b75129a72d373764376a2ba46cac14209d4a93c3 Mon Sep 17 00:00:00 2001 From: Woonki Moon Date: Sat, 28 Jan 2023 22:21:21 +0900 Subject: [PATCH 2/4] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a01ad46b20..568640f0c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ These are only breaking changes for unformatted code. - In GenType, check annotations also in module types to decide whether to produce the `.gen.tsx` file https://github.com/rescript-lang/rescript-compiler/pull/5903 - Fix some comments disappearing in array access expressions https://github.com/rescript-lang/rescript-compiler/pull/5947 - Parser: fix location of variable when function definition `{v => ...}` is enclosed in braces https://github.com/rescript-lang/rescript-compiler/pull/5949 +- Fixed an issue where error messages related to non-existent props were displayed without location information https://github.com/rescript-lang/rescript-compiler/pull/5960 #### :nail_care: Polish From 41c2a6bef78c15f868e7380f13e33622a83a91a1 Mon Sep 17 00:00:00 2001 From: Woonki Moon Date: Sat, 28 Jan 2023 22:31:39 +0900 Subject: [PATCH 3/4] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 568640f0c1..e8c0b0b65a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,7 +50,7 @@ These are only breaking changes for unformatted code. - In GenType, check annotations also in module types to decide whether to produce the `.gen.tsx` file https://github.com/rescript-lang/rescript-compiler/pull/5903 - Fix some comments disappearing in array access expressions https://github.com/rescript-lang/rescript-compiler/pull/5947 - Parser: fix location of variable when function definition `{v => ...}` is enclosed in braces https://github.com/rescript-lang/rescript-compiler/pull/5949 -- Fixed an issue where error messages related to non-existent props were displayed without location information https://github.com/rescript-lang/rescript-compiler/pull/5960 +- Fix an issue where error messages related to non-existent props were displayed without location information https://github.com/rescript-lang/rescript-compiler/pull/5960 #### :nail_care: Polish From a7d79178f8b29e6fea515645ae38ac97688979ab Mon Sep 17 00:00:00 2001 From: Woonki Moon Date: Sat, 28 Jan 2023 22:33:01 +0900 Subject: [PATCH 4/4] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8c0b0b65a..15184700f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,7 +50,7 @@ These are only breaking changes for unformatted code. - In GenType, check annotations also in module types to decide whether to produce the `.gen.tsx` file https://github.com/rescript-lang/rescript-compiler/pull/5903 - Fix some comments disappearing in array access expressions https://github.com/rescript-lang/rescript-compiler/pull/5947 - Parser: fix location of variable when function definition `{v => ...}` is enclosed in braces https://github.com/rescript-lang/rescript-compiler/pull/5949 -- Fix an issue where error messages related to non-existent props were displayed without location information https://github.com/rescript-lang/rescript-compiler/pull/5960 +- Fix issue where error messages related to non-existent props were displayed without location information https://github.com/rescript-lang/rescript-compiler/pull/5960 #### :nail_care: Polish