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

Conversation

cristianoc
Copy link
Collaborator

Fixes #7544

Fix an issue in type checking partial application in the presence of user-defined function types. The type checking code, when extracting the arity of the type annotation given to a function being applied, was expecting a concrete function type instead of looking up a possible type definition.

Fixes #7544

Fix an issue in type checking partial application in the presence of user-defined function types.
The type checking code, when extracting the arity of the type annotation given to a function being applied, was expecting a concrete function type instead of looking up a possible type definition.
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue in type checking for partial application when using user-defined function types. It adds tests in both ReScript and JavaScript for partial application with a user-defined type, and adjusts the type extraction logic in the compiler to look up the proper function type arity.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
tests/tests/src/PartialApplicationNoRuntimeCurry.res Adds tests for partial application with a user-defined function type.
tests/tests/src/PartialApplicationNoRuntimeCurry.mjs Adds corresponding JS tests for partial application.
compiler/ml/typecore.ml Updates type extraction logic to correctly handle user-defined types.
CHANGELOG.md Updates the changelog to reflect the fix.
Comments suppressed due to low confidence (1)

tests/tests/src/PartialApplicationNoRuntimeCurry.res:10

  • [nitpick] The new definition of 'add' may shadow the earlier function 'add' defined on line 1. Consider renaming it (e.g., 'add2' or 'add_fn2') to avoid potential confusion in the test file.
let add: fn2 = (a, b) => a + b

Copy link
Collaborator

@zth zth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet!

@cristianoc cristianoc enabled auto-merge (rebase) June 13, 2025 11:47
@cristianoc cristianoc disabled auto-merge June 13, 2025 11:58
@cristianoc cristianoc merged commit 34ebfe0 into master Jun 13, 2025
10 of 11 checks passed
@cristianoc cristianoc deleted the partial-app-type-def branch June 13, 2025 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding type annotation to curried function emits compiler error
2 participants