Skip to content

Fix issue with partial application and user defined types. #7548

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
Jun 13, 2025
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 @@ -36,6 +36,7 @@
- Fix `index out of bounds` exception thrown in rare cases by `rescript-editor-analysis.exe codeAction` command. https://github.com/rescript-lang/rescript/pull/7523
- Don't produce duplicate type definitions for recursive types on hover. https://github.com/rescript-lang/rescript/pull/7524
- Prop punning when types don't match results in I/O error: _none_: No such file or directory. https://github.com/rescript-lang/rescript/pull/7533
- Fix partial application with user-defined function types. https://github.com/rescript-lang/rescript/pull/7548

#### :nail_care: Polish

Expand Down
5 changes: 2 additions & 3 deletions compiler/ml/typecore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3481,10 +3481,9 @@ and type_application ~context total_app env funct (sargs : sargs) :
| _ -> false
in
let has_arity funct =
let t = funct.exp_type in
if force_tvar then Some (List.length sargs)
else
match (Ctype.repr t).desc with
match (expand_head env funct.exp_type).desc with
| Tarrow (_, _, _, _, Some arity) -> Some arity
| _ -> None
in
Expand Down Expand Up @@ -3538,7 +3537,7 @@ and type_application ~context total_app env funct (sargs : sargs) :
| _ -> new_t
in
(fully_applied, new_t)
| _ -> (false, new_t)
| None -> (false, new_t)
in
let rec type_unknown_args max_arity ~(args : lazy_args) ~top_arity omitted
ty_fun (syntax_args : sargs) : targs * _ =
Expand Down
11 changes: 10 additions & 1 deletion tests/tests/src/PartialApplicationNoRuntimeCurry.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,17 @@ function f(u) {
return extra => f$1(1, extra);
}

function add$1(a, b) {
return a + b | 0;
}

function add5(extra) {
return 5 + extra | 0;
}

export {
add,
f,
add$1 as add,
add5,
}
/* No side effect */
7 changes: 5 additions & 2 deletions tests/tests/src/PartialApplicationNoRuntimeCurry.res
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
@@uncurried

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

let f = u => {
let f = add(u)
f(1, ...)
}

// Test partial application with user-defined function type
type fn2 = (int, int) => int
let add: fn2 = (a, b) => a + b
let add5: int => int = add(5, ...)
Loading