Skip to content

Commit 962e5fb

Browse files
authored
Fix local type variables breaking react components in uncurried mode (rescript-lang#6668)
* test(react-ppx): breaking test for newtype in uncurried mode * fix(react-ppx): don't ignore newtypes in uncurried mode * docs: update changelog * style: formatting
1 parent daf49ba commit 962e5fb

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#### :bug: Bug Fix
1616

1717
- Fix making the static import for the dynamic import of external ffi https://github.com/rescript-lang/rescript-compiler/pull/6664
18+
- Fix local type variables breaking react components. https://github.com/rescript-lang/rescript-compiler/pull/6665
1819

1920
#### :nail-care: Polish
2021

jscomp/syntax/src/jsx_common.ml

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ let removeArity binding =
5858
match expr.pexp_desc with
5959
| _ when Ast_uncurried.exprIsUncurriedFun expr ->
6060
Ast_uncurried.exprExtractUncurriedFun expr
61+
| Pexp_newtype (label, e) ->
62+
{expr with pexp_desc = Pexp_newtype (label, removeArityRecord e)}
6163
| Pexp_apply (forwardRef, [(label, e)]) ->
6264
{
6365
expr with

jscomp/syntax/tests/ppx/react/expected/newtype.res.txt

+13
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,16 @@ let make = {
9999

100100
\"Newtype"
101101
}
102+
103+
@@uncurried
104+
105+
module Uncurried = {
106+
type props<'foo> = {foo?: 'foo}
107+
108+
let make = (type a, {?foo, _}: props<_>) => React.null
109+
let make = {
110+
let \"Newtype$Uncurried" = (props: props<_>) => make(props)
111+
112+
\"Newtype$Uncurried"
113+
}
114+
}

jscomp/syntax/tests/ppx/react/newtype.res

+7-1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,10 @@ module V4A3 = {
4545
}
4646

4747
@react.component
48-
let make =(~x : ('a,'b), ~q:'a ) => [fst(x), q]
48+
let make =(~x : ('a,'b), ~q:'a ) => [fst(x), q]
49+
50+
@@uncurried
51+
52+
module Uncurried = {
53+
@react.component
54+
let make = (type a, ~foo=?) => React.null}

0 commit comments

Comments
 (0)