Use type annotations from arguments in let rec#12315
Merged
stedolan merged 1 commit intoocaml:trunkfrom Jun 21, 2023
Merged
Conversation
gasche
approved these changes
Jun 20, 2023
Member
gasche
left a comment
There was a problem hiding this comment.
The patch looks correct to me, and I agree that it is a reasonable extension of the current behavior.
(Is the absence of a Changes entry intentional?)
| Error: This expression has type int but an expression was expected of type | ||
| string | ||
| |}] | ||
|
|
Member
There was a problem hiding this comment.
Could you include a case of optional argument, to make sure that this is handled correctly?
Contributor
Author
Nope, just hadn't written it yet. |
e93a382 to
d6f3c6c
Compare
Member
|
I fear that the merge of #12210 broke the new test. Sorry about this collision. |
d6f3c6c to
155690a
Compare
Member
|
I rebased the PR (by force-pushing to the remote branch) to the new testsuite output. |
Contributor
Author
|
Thanks for rebasing! |
stedolan
added a commit
to stedolan/ocaml
that referenced
this pull request
Jul 25, 2023
Merged
stedolan
added a commit
to stedolan/ocaml
that referenced
this pull request
Jul 25, 2023
gasche
added a commit
that referenced
this pull request
Jul 25, 2023
voodoos
added a commit
to voodoos/ocaml
that referenced
this pull request
Feb 12, 2025
voodoos
added a commit
to voodoos/ocaml
that referenced
this pull request
Feb 17, 2025
voodoos
added a commit
to voodoos/ocaml
that referenced
this pull request
Feb 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When typing
let recexpressions, the compiler 'approximates' the type of each binding, allowing it to use information about each binding during typechecking. For instance, in alet recof functions, it knows the arity of each definition early, allowing it to produce partial application warnings for mutually recursive functions.Currently, type annotations on function parameters are ignored during this approximation. This delays typechecking errors, often in a confusing way. This patch makes approximation use these type annotations. As well as improving errors, this also makes type-based disambiguation work in more cases, for instance:
With this patch, the above typechecks, because the compiler knows that
gacceptsM.tbefore typing the body off.