Hint on type error on int operators #2307
Add an hint when using
The hint is only enabled on
I made a small refactor of the
gasche left a comment
I believe that the code is correct, and the feature is a user-improvement. The patch was a bit painful to review (the refactorings mixed with the actual feature makes it a bit unpleasant; in particular, 717ad28 could be split in changes to parameter-passing and the actual feature), but the tests give me a fair amount of confidence.
I spotted a few readability improvements that you could make.
One thing that I think is not optimal is that the three error-hint logics are all performed in different ways at the point we call
It's a shame that we have these three different passing protocol. I think a nicer API would be something like
Back in May we had a development meeting where this specific feature was discussed, following the crticism expressed in #2319 (comment) (that the compiler should not hardcode logic that detects identifiers from the standard library; a more general library-level mechanism should be used instead). Personally I think that the current PR is worth having in the compiler codebase, but there was a majority of other maintainers that preferred to wait for a more principled solution, so we decided to revert this PR -- before 4.09, which I still have to do.
I have tried to build a proposal for what a more general mechanism would look like, but my attempts at getting something reasonably nice have not reached a satisfying point for now, so I have nothing to propose. (The difficulty is to find a formulation that is reasonably independent of the specific details of the implementation of type inference in the OCaml compiler.)