WIP: Fix incorrect backtraces for errors in certain boolean expressions (DO NOT MERGE, but please discuss) #3067
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a bit like playing an endless game of whack-a-mole, or putting lipstick on a pig, of course -- the proper fix would be to rewrite the code tracking subexpressions inside statements, but that's a bigger change, so let's fix #3044 the simple way.
The first commit adds a couple of tests that reproduce #3044 and various more or less related issues.
The second commit fixes the problem, and updates the tests. By looking at just the diff for the second commit, you can thus easily see how those cases changed.
But after implementing this, I realized that there are many more similar issues, requiring lots of manual changes... or a sledgehammer approach to try to get rid of all of them at once. The third and fourth commit represent two different approaches to doing that, with different pros and cons. Note that the fourth commit is a hack, and probably introduces too much over head anyway, which is why I did not bother to clean it up; but it is good to see it "for comparison". Also, in fact, all of these changes may cause performance regressions, and should be benchmarked.
As discussed recently in St Andrews, even if one ignores all practical obstacles, part of the issue here is that it is not always clear what's "best" to print. I.e., even if we ignore the question "how to implement the desired behaviour?", it is not even clear what the desired behaviour is.