Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix caching of export declarations #4556

Merged
merged 9 commits into from
Sep 19, 2023

Conversation

keyboardDrummer
Copy link
Member

Changes

  • Change the direction of the dependency between a module and its export declarations, so that the exports depends on the module instead of the other way around. The containing module already depends on the import declarations it contains, and now the export declaration indirectly depend on those imports as well. So if the imported modules change, the export declaration is recreated and resolved.

Testing

  • Added XUnit test that reproduces the problem
  • Manually testing that this particular caching issue no longer occurs

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

ApplyChange(ref imported, ((0, 0), (0, 0)), "//comment" + Environment.NewLine);
ApplyChange(ref importer, ((2, 18), (2, 19)), "true");
var diagnostics2 = await diagnosticsReceiver.AwaitNextDiagnosticsAsync(CancellationToken);
Assert.Single(diagnostics2.Where(d => d.Severity == DiagnosticSeverity.Error));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to understand first, what is this testing? What was the behavior before? Wasn't the error reported and why?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error was not reported because of an internal exception, and that occurred because the ExportModuleDecl was retrieved from a cache when it should not have, which caused its references to be outdated, which caused a dictionary lookup failure.

@@ -18,6 +18,36 @@ namespace Microsoft.Dafny.LanguageServer.IntegrationTest.Various {
public class CompilationStatusNotificationTest : ClientBasedLanguageServerTest {
private const int MaxTestExecutionTimeMs = 10000;

[Fact]
public async Task DidOpenOfEquivalentDocumentDoesNotTriggerCompilation() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test unrelated to the rest of the PR. Just had it laying around.

MikaelMayer
MikaelMayer previously approved these changes Sep 18, 2023
Copy link
Member

@MikaelMayer MikaelMayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, great to see more fix of export declarations.

@keyboardDrummer keyboardDrummer merged commit ae0110f into dafny-lang:master Sep 19, 2023
18 checks passed
@keyboardDrummer keyboardDrummer deleted the exportDeclCaching branch September 19, 2023 14:28
TaBo2410 added a commit that referenced this pull request Sep 20, 2023
…iment-trsplitexpr

* commit '86840e6b14386c1e88480854dd8ce64ad17cb2ff':
  Map eq range (#4567)
  Fix: Declarations with {:only} ensure that other declarations aren't displayed as verified in the gutter icons (#4433)
  Fix caching of export declarations (#4556)
  Do not return exceptions when doing hover in a program with parse errors (#4557)
  Proof dependency warnings (#4542)
  [Test Generation] Reduce memory footprint by reusing the same Boogie program for multiple test generation queries (#4530)
  Fix a variety of bugs in Rust backend based on ESDK testing (#4538)
  Checker for .Values and .Items on maps (#4551)
  feat: Allow more assumptions in library backend (#4545)
  feat: Attributes on reads clauses (#4554)
  Fix gutter icons fields (#4549)
  Report errors that occur in the project file, in the IDE as well (#4539)
  Switch to ubuntu-20.04 for the refman build (#4555)
keyboardDrummer added a commit that referenced this pull request Sep 26, 2023
### Changes
- Change the direction of the dependency between a module and its export
declarations, so that the exports depends on the module instead of the
other way around. The containing module already depends on the import
declarations it contains, and now the export declaration indirectly
depend on those imports as well. So if the imported modules change, the
export declaration is recreated and resolved.

### Testing
- Added XUnit test that reproduces the problem
- Manually testing that this particular caching issue no longer occurs

<small>By submitting this pull request, I confirm that my contribution
is made under the terms of the [MIT
license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants