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

Commit 2a017ca

Browse files
authored
Fix build error where aliasing argument to _ in make function with jsx v4 (#720)
1 parent d56c139 commit 2a017ca

File tree

4 files changed

+58
-4
lines changed

4 files changed

+58
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
- Fix issue where the JSX fragment without children build error https://github.com/rescript-lang/syntax/pull/704
5252
- Fix issue where async as an id cannot be used with application and labelled arguments https://github.com/rescript-lang/syntax/issues/707
5353
- 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
54+
- Fix build error where aliasing arguments to `_` in the make function with JSX V4. https://github.com/rescript-lang/syntax/pull/720
5455

5556
#### :eyeglasses: Spec Compliance
5657

cli/reactjs_jsx_v4.ml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,10 +1082,7 @@ let transformStructureItem ~config mapper item =
10821082
| Pexp_fun
10831083
( _arg_label,
10841084
_default,
1085-
{
1086-
ppat_desc =
1087-
Ppat_construct ({txt = Lident "()"}, _) | Ppat_any;
1088-
},
1085+
{ppat_desc = Ppat_construct ({txt = Lident "()"}, _)},
10891086
expr ) ->
10901087
(patternsWithLabel, patternsWithNolabel, expr)
10911088
| Pexp_fun

tests/ppx/react/aliasProps.res

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@@jsxConfig({version: 4, mode: "automatic"})
2+
3+
module C0 = {
4+
@react.component
5+
let make = (~priority as _, ~text="Test") => React.string(text)
6+
}
7+
8+
module C1 = {
9+
@react.component
10+
let make = (~priority as p, ~text="Test") => React.string(p ++ text)
11+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
@@jsxConfig({version: 4, mode: "automatic"})
2+
3+
module C0 = {
4+
type props<'priority, 'text> = {
5+
priority: 'priority,
6+
text?: 'text,
7+
}
8+
9+
@react.component
10+
let make = ({priority: _, ?text, _}: props<'priority, 'text>) => {
11+
let text = switch text {
12+
| Some(text) => text
13+
| None => "Test"
14+
}
15+
16+
React.string(text)
17+
}
18+
let make = {
19+
let \"AliasProps$C0" = (props: props<_>) => make(props)
20+
21+
\"AliasProps$C0"
22+
}
23+
}
24+
25+
module C1 = {
26+
type props<'priority, 'text> = {
27+
priority: 'priority,
28+
text?: 'text,
29+
}
30+
31+
@react.component
32+
let make = ({priority: p, ?text, _}: props<'priority, 'text>) => {
33+
let text = switch text {
34+
| Some(text) => text
35+
| None => "Test"
36+
}
37+
38+
React.string(p ++ text)
39+
}
40+
let make = {
41+
let \"AliasProps$C1" = (props: props<_>) => make(props)
42+
43+
\"AliasProps$C1"
44+
}
45+
}

0 commit comments

Comments
 (0)