Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Break out of loop in
Printtyp.best_type_path
when path gets long
The code in `Printtyp.best_type_path` assumes that if the path is not in the printing env, it must be the case that adding more to the printing depth will eventually succeed in putting it there. However, if something has gone wrong, the path might just be missing from the printing env altogether, in which case the loop continues searching to arbitrary depths. If _two_ things have gone wrong, there might be a self-reference lurking in the environment, meaning the search can go to arbitrary depth without running out of paths to traverse. We can cut off both scenarios by breaking out of the loop as soon as the printing depth is as big as the best candidate so far, since from that point increasing the depth cannot help. This change also returns the original path in cases where the normalised one is longer. This may cut down on cases where paths with double underscores are seen in error messages.
- Loading branch information