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 angry module LSP diagnostic #6086

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/DafnyCore/AST/Modules/ModuleDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ public bool Resolve(ModuleSignature sig, ModuleResolver resolver, string exportS
if (!nestedModuleDecl.ModuleDef.SuccessfullyResolved) {
if (!IsEssentiallyEmptyModuleBody()) {
// say something only if this will cause any testing to be omitted
resolver.reporter.Error(MessageSource.Resolver, nestedModuleDecl,
resolver.reporter.Error(MessageSource.Resolver, nestedModuleDecl.NameNode,
"not resolving module '{0}' because there were errors in resolving its nested module '{1}'", Name,
nestedModuleDecl.Name);
}
Expand Down
20 changes: 20 additions & 0 deletions Source/DafnyLanguageServer.Test/Diagnostics/DiagnosticsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,26 @@ namespace Microsoft.Dafny.LanguageServer.IntegrationTest.Synchronization {
public class DiagnosticsTest : ClientBasedLanguageServerTest {
private readonly string testFilesDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Synchronization/TestFiles");

[Fact]
public async Task NestedModuleRange() {
var source = @"
module A {
function A(x: int): int {
true
}
function B(x: int): int {
1
}
}
method Main() {
}".TrimStart();
var documentItem = CreateAndOpenTestDocument(source);
var diagnostics1 = await GetLastDiagnostics(documentItem);
var startOrdered = diagnostics1.OrderBy(r => r.Range.Start).ToList();
Assert.Equal(new Range(0, 7, 0, 8), startOrdered[0].Range);
Assert.Equal(new Range(1, 2, 3, 3), startOrdered[1].Range);
}

[Fact]
public async Task ResolutionErrorMigration() {
var source = @"module ResolutionError {
Expand Down
Loading