Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 380440e

Browse files
authored
Add the missing loc of jsx call expression (#730)
1 parent 08a18fe commit 380440e

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
- Fix parsing of spread props as an expression in JSX V4 https://github.com/rescript-lang/syntax/pull/721
5757
- Fix dropping attributes from props in make function in JSX V4 https://github.com/rescript-lang/syntax/pull/723
5858
- Fix an issue where error messages related to duplicate props were displayed without a loc and were unclear https://github.com/rescript-lang/syntax/pull/728
59+
- Fix issue where error messages related to non-existent props were displayed without location information https://github.com/rescript-lang/syntax/pull/730
5960

6061
#### :eyeglasses: Spec Compliance
6162

cli/reactjs_jsx_v4.ml

+7-6
Original file line numberDiff line numberDiff line change
@@ -437,24 +437,25 @@ let transformUppercaseCall3 ~config modulePath mapper jsxExprLoc callExprLoc
437437
( Exp.ident {loc = Location.none; txt = Ldot (Lident "React", "jsxs")},
438438
[] )
439439
in
440-
Exp.apply ~attrs jsxExpr ([(nolabel, makeID); (nolabel, props)] @ keyAndUnit)
440+
Exp.apply ~loc:jsxExprLoc ~attrs jsxExpr
441+
([(nolabel, makeID); (nolabel, props)] @ keyAndUnit)
441442
| _ -> (
442443
match (!childrenArg, keyProp) with
443444
| None, key :: _ ->
444-
Exp.apply ~attrs
445+
Exp.apply ~loc:jsxExprLoc ~attrs
445446
(Exp.ident
446447
{
447448
loc = Location.none;
448449
txt = Ldot (Lident "JsxPPXReactSupport", "createElementWithKey");
449450
})
450451
[key; (nolabel, makeID); (nolabel, props)]
451452
| None, [] ->
452-
Exp.apply ~attrs
453+
Exp.apply ~loc:jsxExprLoc ~attrs
453454
(Exp.ident
454455
{loc = Location.none; txt = Ldot (Lident "React", "createElement")})
455456
[(nolabel, makeID); (nolabel, props)]
456457
| Some children, key :: _ ->
457-
Exp.apply ~attrs
458+
Exp.apply ~loc:jsxExprLoc ~attrs
458459
(Exp.ident
459460
{
460461
loc = Location.none;
@@ -463,7 +464,7 @@ let transformUppercaseCall3 ~config modulePath mapper jsxExprLoc callExprLoc
463464
})
464465
[key; (nolabel, makeID); (nolabel, props); (nolabel, children)]
465466
| Some children, [] ->
466-
Exp.apply ~attrs
467+
Exp.apply ~loc:jsxExprLoc ~attrs
467468
(Exp.ident
468469
{
469470
loc = Location.none;
@@ -544,7 +545,7 @@ let transformLowercaseCall3 ~config mapper jsxExprLoc callExprLoc attrs
544545
( Exp.ident {loc = Location.none; txt = Ldot (Lident "ReactDOM", "jsxs")},
545546
[] )
546547
in
547-
Exp.apply ~attrs jsxExpr
548+
Exp.apply ~loc:jsxExprLoc ~attrs jsxExpr
548549
([(nolabel, componentNameExpr); (nolabel, props)] @ keyAndUnit)
549550
| _ ->
550551
let children, nonChildrenProps =

tests/ppx/react/expected/forwardRef.res.txt

+1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ module V4A = {
166166
@react.component
167167
let make = (_: props) => {
168168
let input = React.useRef(Js.Nullable.null)
169+
169170
ReactDOM.jsx(
170171
"div",
171172
{

0 commit comments

Comments
 (0)