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

Add loc for returned component body #633

Merged
merged 3 commits into from
Sep 14, 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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion cli/reactjs_jsx_ppx.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/ppx/react/expected/commentAtTop.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ let make = ({msg, _}: props<'msg>) => {
}
let make = {
let \"CommentAtTop" = (props: props<_>) => make(props)

\"CommentAtTop"
}
2 changes: 2 additions & 0 deletions tests/ppx/react/expected/fileLevelConfig.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module V4C = {
}
let make = {
let \"FileLevelConfig$V4C" = (props: props<_>) => make(props)

\"FileLevelConfig$V4C"
}
}
Expand All @@ -40,6 +41,7 @@ module V4A = {
}
let make = {
let \"FileLevelConfig$V4A" = (props: props<_>) => make(props)

\"FileLevelConfig$V4A"
}
}
4 changes: 4 additions & 0 deletions tests/ppx/react/expected/forwardRef.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ module V4C = {
)
let make = React.forwardRef({
let \"ForwardRef$V4C$FancyInput" = (props: props<_>, ref) => make(props, ref)

\"ForwardRef$V4C$FancyInput"
})
}
Expand All @@ -114,6 +115,7 @@ module V4C = {
}
let make = {
let \"ForwardRef$V4C" = props => make(props)

\"ForwardRef$V4C"
}
}
Expand Down Expand Up @@ -149,6 +151,7 @@ module V4A = {
)
let make = React.forwardRef({
let \"ForwardRef$V4A$FancyInput" = (props: props<_>, ref) => make(props, ref)

\"ForwardRef$V4A$FancyInput"
})
}
Expand All @@ -169,6 +172,7 @@ module V4A = {
}
let make = {
let \"ForwardRef$V4A" = props => make(props)

\"ForwardRef$V4A"
}
}
2 changes: 2 additions & 0 deletions tests/ppx/react/expected/newtype.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module V4C = {
ReactDOMRe.createDOMElementVariadic("div", [])
let make = {
let \"Newtype$V4C" = (props: props<_>) => make(props)

\"Newtype$V4C"
}
}
Expand All @@ -45,6 +46,7 @@ module V4A = {
ReactDOM.jsx("div", {key: ?None})
let make = {
let \"Newtype$V4A" = (props: props<_>) => make(props)

\"Newtype$V4A"
}
}
2 changes: 2 additions & 0 deletions tests/ppx/react/expected/topLevel.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module V4C = {
}
let make = {
let \"TopLevel$V4C" = (props: props<_>) => make(props)

\"TopLevel$V4C"
}
}
Expand All @@ -44,6 +45,7 @@ module V4A = {
}
let make = {
let \"TopLevel$V4A" = (props: props<_>) => make(props)

\"TopLevel$V4A"
}
}
2 changes: 2 additions & 0 deletions tests/ppx/react/expected/typeConstraint.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module V4C = {
ReactDOMRe.createDOMElementVariadic("div", [])
let make = {
let \"TypeConstraint$V4C" = (props: props<_>) => make(props)

\"TypeConstraint$V4C"
}
}
Expand All @@ -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"
}
}
1 change: 1 addition & 0 deletions tests/ppx/react/expected/v4.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}