Skip to content

Fix issue where partial application ... can use Curry at runtime. #6872

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 @@ -42,6 +42,7 @@
- Reactivate unused attribute check for `@int`. https://github.com/rescript-lang/rescript-compiler/pull/6802
- Fix Deno compatibility issues on Windows. https://github.com/rescript-lang/rescript-compiler/pull/6850
- Fix issue with infinite loops with type errors on recursive types. https://github.com/rescript-lang/rescript-compiler/pull/6867
- Fix issue where using partial application `...` can generate code that uses `Curry` at runtime. https://github.com/rescript-lang/rescript-compiler/pull/6872

#### :house: Internal

Expand Down
8 changes: 4 additions & 4 deletions jscomp/ml/translcore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1099,16 +1099,16 @@ and transl_apply ?(inlined = Default_inline) ?(uncurried_partial_application=Non
let id_arg = Ident.create "none" in
none_ids := id_arg :: !none_ids;
Some (Lvar id_arg)) in
let extra_ids = ref [] in
extra_ids := Ident.create "extra" :: !extra_ids;
let extra_ids = Array.init extra_arity (fun _ -> Ident.create "extra") |> Array.to_list in
let extra_args = Ext_list.map extra_ids (fun id -> Lvar id) in
let ap_args = args @ extra_args in
let l0 = Lapply { ap_func = lam; ap_args; ap_inlined = inlined; ap_loc = loc } in
let lam_opaque = Lprim (Popaque, [lam], loc) in
let l0 = Lapply { ap_func = lam_opaque; ap_args; ap_inlined = inlined; ap_loc = loc } in
let l1 = Lprim (Puncurried_apply, [l0], loc) in
Lfunction
{
params = List.rev_append !none_ids extra_ids ;
body = l0;
body = l1;
attr = default_function_attribute;
loc;
}
Expand Down
20 changes: 20 additions & 0 deletions jscomp/test/PartialApplicationNoRuntimeCurry.js

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

8 changes: 8 additions & 0 deletions jscomp/test/PartialApplicationNoRuntimeCurry.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@@uncurried

let add = x => (y, z) => x + y + z

let f = u => {
let f = add(u)
f(1, ...)
}
6 changes: 1 addition & 5 deletions jscomp/test/UncurriedAlways.js

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

3 changes: 2 additions & 1 deletion jscomp/test/build.ninja

Large diffs are not rendered by default.