fix: ensure postcondition expression is extracted from the right URI #3044
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.
The following bug requires two Dafny files, one containing an abstract module and another one refining it, like these:
The command line tool gives reasonable output: it indicates that a postcondition might not hold, and points to the
ensures
in the abstract module by indicating the file, line, and column value:However, the language server attempts to concretise the postcondition by slicing a substring out of the failing program source. The server assumes that the postcondition is in the current document - in the case of module refinement, this isn't the case. Thus, we get a nonsensical error:
Those are, of course, the characters corresponding to the postcondition, but in the current file, not the file that actually contains it! (one can add or remove characters early on in the file and watch the garbage postcondition "slide around").
This patch ensures that when extracting substrings from a document, the right URI is used. (This patch cleans up a bit of the existing logic: there was a "default" error message for the "Related location" case that would never get hit, etc)
I will push another commit with the release notes modified, once I create this pull request and am assigned a PR number from GitHub.Additionally: I'm not sure how to write a
git-issue
test for this, since two Dafny files are required to trigger the issue. What would you like me to do?Cheers,
Nathan