Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix error submessages in the toplevel: do not display dummy locations #8954
When an error sub-message is equipped with a ghost location, the error printing code should not print the location. This is done properly by the "batch mode" printer (used by
This PR fixes the toplevel printer for ANSI terminals accordingly, and closes #8953.
I wanted to add a test, but it turns out that it is not possible using our current testing pipeline. Indeed, both inline tests and "toplevel" tests use the "batch mode" printer. To exercise the other printer, one would need to execute the tests while simulating an ANSI-capable terminal; this is not done currently anywhere as far as I'm aware.
I tried to look at the
It looks like the following functions are worth reviewing, to think about their intended behavior on ghost locations:
(Fun story time!
I remember finding out that there are indeed several places in the code where dummy and/or ghost locations leak out and end up being printed, and that cleaning up is not always easy (I think there is at least an instance of the typechecker emitting meaningful-but-ghost locations).
My perception of the current API provided by
With that in mind, I believe that there are indeed issues with how other parts of the compiler use the "unsafe" API, but that these are mostly orthogonal to the issue here (which is related to the implementation of the "safe" API).
I don't understand the logic in this paragraph. If those functions are part of the implementation of a printer, they should be careful about ghost locations, shouldn't they?
I don't have time to think deeply about this, and it looks like you have, somewhat -- and I don't expect you to spend more time on it. So let's consider that we have performed due diligence and merge the PR.
My reasoning is as follows:
A printer is composed of an entry point (
Thanks for approving the PR.