Skip to content

Avoid generating calls to Curry when adjusting arity of uncurried f… #6870

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
Jul 12, 2024
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 @@ -58,6 +58,7 @@
- Make tests ready for uncurried mode. https://github.com/rescript-lang/rescript-compiler/pull/6862
- Make gentype tests uncurried. https://github.com/rescript-lang/rescript-compiler/pull/6866
- Ignore `@uncurry` attribute in uncurried mode, to avoid generating calls to `Curry` at runtime. https://github.com/rescript-lang/rescript-compiler/pull/6869
- Avoid generating calls to Curry when adjusting arity of uncurried functions. https://github.com/rescript-lang/rescript-compiler/pull/6870

#### :nail_care: Polish

Expand Down
6 changes: 5 additions & 1 deletion jscomp/core/lam_eta_conversion.ml
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,13 @@ let unsafe_adjust_to_arity loc ~(to_ : int) ?(from : int option) (fn : Lam.t) :
let extra_args =
Ext_list.init (to_ - from) (fun _ -> Ident.create Literals.param)
in
let rec mk_apply body vars = match vars with
| [] -> body
| var :: vars ->
mk_apply (Lam.apply body [var] ap_info) vars in
Lam.function_ ~attr:Lambda.default_function_attribute ~arity:to_
~params:(Ext_list.append params extra_args)
~body:(Lam.apply body (Ext_list.map extra_args Lam.var) ap_info)
~body:(mk_apply body (Ext_list.map extra_args Lam.var))
| _ -> (
let arity = to_ in
let extra_args =
Expand Down
8 changes: 4 additions & 4 deletions jscomp/test/mutable_uncurry_test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.