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

Fix build error where aliasing argument to _ in make function with jsx v4 #720

Merged
merged 3 commits into from
Dec 7, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
- Fix issue where the JSX fragment without children build error https://github.com/rescript-lang/syntax/pull/704
- Fix issue where async as an id cannot be used with application and labelled arguments https://github.com/rescript-lang/syntax/issues/707
- Treat await as almost-unary operator weaker than pipe so `await foo->bar` means `await (foo->bar)` https://github.com/rescript-lang/syntax/pull/711
- Fix build error where aliasing arguments to `_` in the make function with JSX V4. https://github.com/rescript-lang/syntax/pull/720

#### :eyeglasses: Spec Compliance

Expand Down
5 changes: 1 addition & 4 deletions cli/reactjs_jsx_v4.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1082,10 +1082,7 @@ let transformStructureItem ~config mapper item =
| Pexp_fun
( _arg_label,
_default,
{
ppat_desc =
Ppat_construct ({txt = Lident "()"}, _) | Ppat_any;
},
{ppat_desc = Ppat_construct ({txt = Lident "()"}, _)},
expr ) ->
(patternsWithLabel, patternsWithNolabel, expr)
| Pexp_fun
Expand Down
11 changes: 11 additions & 0 deletions tests/ppx/react/aliasProps.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@@jsxConfig({version: 4, mode: "automatic"})

module C0 = {
@react.component
let make = (~priority as _, ~text="Test") => React.string(text)
}

module C1 = {
@react.component
let make = (~priority as p, ~text="Test") => React.string(p ++ text)
}
45 changes: 45 additions & 0 deletions tests/ppx/react/expected/aliasProps.res.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
@@jsxConfig({version: 4, mode: "automatic"})

module C0 = {
type props<'priority, 'text> = {
priority: 'priority,
text?: 'text,
}

@react.component
let make = ({priority: _, ?text, _}: props<'priority, 'text>) => {
let text = switch text {
| Some(text) => text
| None => "Test"
}

React.string(text)
}
let make = {
let \"AliasProps$C0" = (props: props<_>) => make(props)

\"AliasProps$C0"
}
}

module C1 = {
type props<'priority, 'text> = {
priority: 'priority,
text?: 'text,
}

@react.component
let make = ({priority: p, ?text, _}: props<'priority, 'text>) => {
let text = switch text {
| Some(text) => text
| None => "Test"
}

React.string(p ++ text)
}
let make = {
let \"AliasProps$C1" = (props: props<_>) => make(props)

\"AliasProps$C1"
}
}