Hint when the expected type is wrapped in a ref#2319
Hint when the expected type is wrapped in a ref#2319Julow wants to merge 6 commits intoocaml:trunkfrom
Conversation
|
A meta-comment: in your testsuite entries, it would be nice if you could include a comment in each case describing what you are trying and what is the behavior you expect. Otherwise it's hard to understand why, in a certain case, there is no hint (is this a bug? a not-implemented-yet-feature? a known limitation of the approach? a case where it's good to not hint?). |
|
A meta-meta-comment: References are entirely defined in the standard library. It feels wrong to special-case them in the typechecker, from an architectural standpoint. The same can be said about #2307 (int and float operators are not "known" to the typechecker) but it was hastily merged before I could make that remark. I think this approach is misguided. This kind of error explanations should be declared in the standard library, perhaps as annotations, using some generic mechanism for explanations to be implemented in the typechecker. Not unlike the way Menhir handles user-defined error messages for specific parsing errors. Can we please have a discussion and vote on caml-devel? |
|
Sure, let's have a discussion. Personally I think that, to a common (For the record, I think that the |
|
@xavierleroy I don't think it is a problem on the architecture side. This is part of the error-reporting code, which could be moved to its own module (I'll be happy to do it). |
This PR add an hint suggesting to use the
(!)operatorThis example,
gives:
@Armael tried to implement this before.
I hope I handled all the corner cases and this can be accepted.
This PR is based on top of #2313