-
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
Add two tests for -short-paths
with existential types
#12340
Conversation
71e684a
to
ad1704f
Compare
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.
-short-paths
is surely going to be completely rewritten soon, but this patch is very simple, reasonable and comes with a test, so let's merge it?
manual/src/cmds/unified-options.etex
Outdated
containing double underscores "__" incur a penalty of $+10$ when computing | ||
their length. | ||
warning messages. Identifier names starting with an underscore "_", a | ||
dollar "$" or containing double underscores "__" incur a penalty of |
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.
Shouldn't this be escaped?
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.
tools/texquote2
does escape it automatically.
@trefis I was a bit worried that the shortening logic might also happen within scope escape message leading to variations on Did you have the time to investigate this potential issue? At the same time, many GADTs error messages are already worsened by |
So errr... type _ ty = Char : char ty
type pair = Pair : 'a ty * 'a -> pair
let f = function
| Pair (Char, x) -> if true then x else 'd' And got this before this PR:
Unless something major has changed in this area since 4.14, I'd say it can't be making things worse. |
Thanks for the example!
with |
If that’s not always an improvement, maybe we should forget about it. |
Adding the two examples in the |
ad1704f
to
3007b1c
Compare
$
with -short-paths
-short-paths
with existential types
I’ve renamed this PR and kept only the addition of the two tests. |
^ | ||
Error: This expression has type "$Pair_'a" | ||
but an expression was expected of type "int" | ||
|}] |
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 would add a comment that we would like short-path to print char
rather than $Pair_'a
in this context.
but an expression was expected of type "'a" | ||
This instance of "$Pair_'a" is ambiguous: | ||
it would escape the scope of its 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.
While in this context, it seems better to keep the existential type.
@@ -34,3 +34,35 @@ Line 7, characters 9-18: | |||
Error: This expression has type "c" | |||
It has no method "bar" | |||
|}] | |||
|
|||
type _ ty = Char : char ty |
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.
A short section title would be good to keep track of what those tests are asserting. Something like
(** Known issue: how to print existential types with equality in scope? *)
I think that a change entry "testsuite: collect known issues with current -short-paths implementation" could be useful, after all good test cases are a real necessity when improving error messages. |
Add two tests combining `-short-paths` with existential types to help guide future revisions of the `-short-paths` feature Co-authored-by: Florian Angeletti <florian.angeletti@inria.fr>
3007b1c
to
d9973e8
Compare
Thank you for all those suggestions. I’ve put you as a co-author, at that stage :-) |
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.
(If @Octachron is co-author then you need another approval.)
As
$
is used to prefix existential types, favor an alternative if it exists when-short-paths
is enabled by using exactly the same penalty as for the_
prefix.On the following program:
$ ocamlc -short-paths
reported before:while it now reports:
I'm not sure whether
$
can appear in other cases than existential types.