You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
flambda-backend: Break out of loop in Printtyp.best_type_path when depth gets big (#1961)
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.
0 commit comments