-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Specialized error message for syntactic function arity type clash #12386
Specialized error message for syntactic function arity type clash #12386
Conversation
Your proposal:
I find the "must agree with" sentence too general/formal. I prefer the same message without it:
|
If we want to have a hint which is grammatically valid, I propose to add ellipses:
which from my point view has the advantage of making obvious what we mean by "splitting up the function". I think it would helpful for users on their first reading of the error message to mention the local type abstract blocking the arity in the external view. If I am not mistaken, we can extract this local abstract type by looking up at the last Listing the GADT constructor pattern could be helpful but I believe that we are hitting diminishing return at this point. |
I like both of those suggestions, and I find the reworded hint helpful. In full, with minor tweaks to wording, that would be:
I will look into extracting the locally abstract type's name, as I agree that it helps clarify the message. |
(Is a Changes entry needed? My feeling was no, but I will defer to others.) |
You could add the PR number to the #12236 changes entry. |
Good idea, thanks. And done. |
to "?opt:(a, int -> int) eq -> unit -> a". | ||
Hint: consider splitting up the function's syntactic arity by | ||
inserting "-> fun" after the argument that introduces the local | ||
type equation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the testsuite output is not up-to-date with the error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sorry about that. I pushed a fix just as you left this comment.
9fbf74d
to
e97025b
Compare
Tests from: - ocaml/ocaml#12236 (and the corresponding updates to outputs found in ocaml/ocaml#12386 and ocaml/ocaml#12391) - ocaml/ocaml#12496 (not merged)
Tests from: - ocaml/ocaml#12236 (and the corresponding updates to outputs found in ocaml/ocaml#12386 and ocaml/ocaml#12391) - ocaml/ocaml#12496 (not merged)
Tests from: - ocaml/ocaml#12236 (and the corresponding updates to outputs found in ocaml/ocaml#12386 and ocaml/ocaml#12391) - ocaml/ocaml#12496 (not merged)
Tests from: - ocaml/ocaml#12236 (and the corresponding updates to outputs found in ocaml/ocaml#12386 and ocaml/ocaml#12391) - ocaml/ocaml#12496 (not merged)
Tests from: - ocaml/ocaml#12236 (and the corresponding updates to outputs found in ocaml/ocaml#12386 and ocaml/ocaml#12391) - ocaml/ocaml#12496 (not merged)
Tests from: - ocaml/ocaml#12236 (and the corresponding updates to outputs found in ocaml/ocaml#12386 and ocaml/ocaml#12391) - ocaml/ocaml#12496 (not merged)
Tests from: - ocaml/ocaml#12236 (and the corresponding updates to outputs found in ocaml/ocaml#12386 and ocaml/ocaml#12391) - ocaml/ocaml#12496 (not merged)
Tests from: - ocaml/ocaml#12236 (and the corresponding updates to outputs found in ocaml/ocaml#12386 and ocaml/ocaml#12391) - ocaml/ocaml#12496 (not merged)
Tests from: - ocaml/ocaml#12236 (and the corresponding updates to outputs found in ocaml/ocaml#12386 and ocaml/ocaml#12391) - ocaml/ocaml#12496 (not merged)
Tests from: - ocaml/ocaml#12236 (and the corresponding updates to outputs found in ocaml/ocaml#12386 and ocaml/ocaml#12391) - ocaml/ocaml#12496 (not merged)
* Newtypes * Constraint/coercion * Add map_half_typed_cases * Implement type-checking/translation This also promotes tests whose output changes. * Add upstream tests Tests from: - ocaml/ocaml#12236 (and the corresponding updates to outputs found in ocaml/ocaml#12386 and ocaml/ocaml#12391) - ocaml/ocaml#12496 (not merged) * Fix ocamldoc * Update chamelon minimizer * Respond to requested changes to minimizer * update new test brought in from rebase * Fix bug in chunking code * `make bootstrap` * Add Ast_invariant check * Fix type-directed disambiguation of optional arg defaults * Minor comments from review * Run syntactic-arity test, update output, and fix printing bug * Remove unnecessary call to escape * Backport changes from upstream to comparative alloc tests * Avoid the confusing [Split_function_ty] module * Comment [split_function_ty] better. * [contains_gadt] as variant instead of bool * Calculate is_final_val_param on the fly rather than precomputing indexes * Note suboptimality * Get typecore typechecking * Finish resolving merge conflicts and run tests * make bootstrap * Add iteration on / mapping over locations and attributes * Reduce diff and fix typo in comment: * promote change to zero-alloc arg structure * Undo unintentional formatting changes to chamelon * Fix minimizer * Minimize diff * Fix bug with local-returning method * Fix regression where polymorphic parameters weren't allowed to be used in same parameter list as GADTs * Fix merge conflicts and make bootstrap * Apply expected diff to zero-alloc test changed in this PR
This continues a discussion with @Octachron from #12236. The topic is what error message to generate in a case of typing backward-incompatibility. Here's an example of such a case:
As of #12236, the error message is a generic-looking unification error:
We thought we should do better to explain the problem, especially given that the change to typing is backward-incompatible. I'm making this PR to summarize the ideas so far, suggest a wording, and solicit further refinements/ideas.
(A) First try from original PR that we decided against:
Some remarks that @Octachron made:
(int -> int -> int as 'a) ->'a
is fine.(a, int -> int) eq -> 'a -> 'b
is potentially confusing to include in the output. It doesn't match any type written by the user, so they may struggle to connect it to the main point of the error message.(B) @Octachron 's suggestion that focuses on syntactic arity:
(C) Current draft:
This latest version:
This fix is meant to guide the user to this program, which type-checks:
Here are a few areas of discussion that immediately come to mind:
-> fun
” as the grammatical object is a snippet of text, not a sensible AST. But maybe it is still a good way to guide the user to a type-checking program.