Skip to content

Support uncurried in PPX V3. #6081

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2023
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 @@ -70,6 +70,7 @@ These are only breaking changes for unformatted code.
- Process `@set` annotation for field update as generating an uncurried function https://github.com/rescript-lang/rescript-compiler/pull/5846
- Treat uncurried application of primitives like curried application, which produces better output https://github.com/rescript-lang/rescript-compiler/pull/5851
- New internal representation for uncurried functions using built-in type `function$<fun_type, arity>` this avoids having to declare all the possible arities ahead of time https://github.com/rescript-lang/rescript-compiler/pull/5870
- PPX V3: allow uncurried `make` function and treat it like a curried one https://github.com/rescript-lang/rescript-compiler/pull/6081

# 10.1.4

Expand Down
3 changes: 3 additions & 0 deletions res_syntax/src/reactjs_jsx_v3.ml
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ let jsxMapper ~config =
match List.filter React_jsx_common.hasAttr pval_attributes with
| [] -> [item]
| [_] ->
let pval_type = React_jsx_common.extractUncurried pval_type in
let rec getPropTypes types ({ptyp_loc; ptyp_desc} as fullType) =
match ptyp_desc with
| Ptyp_arrow (name, type_, ({ptyp_desc = Ptyp_arrow _} as rest))
Expand Down Expand Up @@ -648,6 +649,7 @@ let jsxMapper ~config =
let emptyLoc = Location.in_file fileName in
let mapBinding binding =
if React_jsx_common.hasAttrOnBinding binding then
let binding = React_jsx_common.removeArity binding in
let bindingLoc = binding.pvb_loc in
let bindingPatLoc = binding.pvb_pat.ppat_loc in
let binding =
Expand Down Expand Up @@ -1031,6 +1033,7 @@ let jsxMapper ~config =
match List.filter React_jsx_common.hasAttr pval_attributes with
| [] -> [item]
| [_] ->
let pval_type = React_jsx_common.extractUncurried pval_type in
let rec getPropTypes types ({ptyp_loc; ptyp_desc} as fullType) =
match ptyp_desc with
| Ptyp_arrow (name, type_, ({ptyp_desc = Ptyp_arrow _} as rest))
Expand Down