Disregard the attached patch, the condition is the wrong way around and doesn't fix anything once changed.
(Context: I was trying to make sense of ebbf345 , at some point my example wasn't rejected anymore, I thought I had a fix).
Thanks for finding a solution.
This does not explain what the problem is, but I expect it to be a problem with levels in the type of the expression after generalization; one should never use the type of an expression partially generalized. So yes, your solution seems to be right.
I'm willing to merge it, but I have a question: how do I get a patch from your pull request?
The bridge between svn and github only works in one direction...
Thank you for merging and adding a test!
I noticed that as a side effect of my patches, code like the following:
let foo `Test = ()
let wrap f `Test = f
let bar = wrap ()
are now correctly rejected, while they weren't previously.
pr6899_more_tests.patch adds a regression test to ensure this particular code is rejected (as well as another more straightforward bad code).
Do you mind merging that as well?
Note: The piece of code given in example here is also accepted on 4.02.2. I don't know if people are considering doing another minor release at some point, but if yes then the patches should probably be backported on that branch.