Skip to content

Commit ba47799

Browse files
authored
Add the missing loc of jsx call expression (#5960)
1 parent 3df0aee commit ba47799

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ These are only breaking changes for unformatted code.
5050
- 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
5151
- Fix some comments disappearing in array access expressions https://github.com/rescript-lang/rescript-compiler/pull/5947
5252
- Parser: fix location of variable when function definition `{v => ...}` is enclosed in braces https://github.com/rescript-lang/rescript-compiler/pull/5949
53+
- Fix issue where error messages related to non-existent props were displayed without location information https://github.com/rescript-lang/rescript-compiler/pull/5960
5354

5455
#### :nail_care: Polish
5556

Diff for: res_syntax/src/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 =

Diff for: res_syntax/tests/ppx/react/expected/forwardRef.res.txt

+2
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ module V4A = {
223223
@react.component
224224
let make = (_: props) => {
225225
let input = React.useRef(Js.Nullable.null)
226+
226227
ReactDOM.jsx(
227228
"div",
228229
{
@@ -279,6 +280,7 @@ module V4AUncurried = {
279280
@react.component
280281
let make = (_: props) => {
281282
let input = React.useRef(Js.Nullable.null)
283+
282284
ReactDOM.jsx(
283285
"div",
284286
{

0 commit comments

Comments
 (0)