-
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
Fix: Inconsistent type vars in "unbound type var" message #11194
Conversation
The type var should stay coherent in a same error message. This is not the case for "variables unbound" messages.
Hi @Octachron not sure if you are the correct person to ping, sorry if that is not the case :-) |
Thanks for the reminder! I have added the PR to my review stack for next week. |
let ty1 = | ||
if real then ty0 else Btype.newgenty(Tobject(ty0, ref None)) | ||
in | ||
Printtyp.prepare_for_printing [ty; ty1]; |
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.
Moving this preparation here makes it a no-op: printer
is either Printtyp.class_declaration
or Printtyp.cltype_declaration
and both of them call Printtyp.reset_context
undoing the work done by this call.
Moreover, this matters because there is at least one case where Printtyp.class_declaration
does not print itself the method type and thus may not mark cycles which may lead to a stack overflow in the printer(with this PR):
class ['a] c = object method m: (<x:'a; f:'b> as 'b) -> unit = fun _ -> () end
class d = ['a] c
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.
With the way that the printing classes are wired, I fear that the easiest solution would be to add an optional ?(reset=true)
argument to Printtyp.prepare_for_printing
and use it in the suberror message printer.
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.
Ok, thanks for your review and these insights, I will give it more thoughts.
@voodoos : did you have the time to work on this PR? If not would you mind if I submitted my version of the fix? |
I didn't sadly. Feel free to close this and propose your own :-) |
…_context #11194: fix an inconsistency in type variable names in error messages
Superseded by #11609 . |
When upgrading Merlin for 4.14 our test-suite catched the following issue:
In this example the printed type for
method b
is inconsistent.This is due to an extraneous reset of the printer introduced in #10488
This PR add a test illustrating the issue and a fix proposition.