dafny icon indicating copy to clipboard operation
dafny copied to clipboard

Internal error when importing a method using a datatype

Open Pireax opened this issue 2 years ago • 1 comments
trafficstars

Dafny version

4.2.0.0

Code to produce this issue

// InternalErrorInc.dfy
datatype CellState = Empty | Zero | One

method DoSomething(p: CellState)
{
    
}
---
// InternalError.dfy
include "InternalErrorInc.dfy"

class Class
{
    constructor() {}

    method Act(p: CellState)
    {
        DoSomething(p);
    }
}

Command to run and resulting output

Dafny encountered an internal error. Please report it at <https://github.com/dafny-lang/dafny/issues>.
System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Boogie.CallCmd.AddAssignedVariables(List`1 vars)
   at Microsoft.Boogie.Cmd.CheckAssignments(TypecheckingContext tc)
   at Microsoft.Boogie.CallCmd.Typecheck(TypecheckingContext tc)
   at Microsoft.Boogie.Block.Typecheck(TypecheckingContext tc)
   at Microsoft.Boogie.Implementation.Typecheck(TypecheckingContext tc)
   at Microsoft.Boogie.Program.Typecheck(TypecheckingContext tc)
   at Microsoft.Boogie.ExecutionEngine.GetImplementationTasks(Program program)
   at Microsoft.Dafny.LanguageServer.Language.DafnyProgramVerifier.<>c__DisplayClass4_0.<GetVerificationTasksAsync>b__0(Tuple`2 t)
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.ToList()
   at Microsoft.Dafny.LanguageServer.Language.DafnyProgramVerifier.GetVerificationTasksAsync(CompilationAfterResolution compilation, CancellationToken cancellationToken)
   at Microsoft.Dafny.LanguageServer.Workspace.CompilationManager.PrepareVerificationTasksAsync(CompilationAfterResolution loaded, CancellationToken cancellationToken)
   at Microsoft.Dafny.LanguageServer.Workspace.CompilationManager.TranslateAsync()

What happened?

Calling the method DoSomething in a class method causes the error shown. Moving the method definition of DoSomething to the InternalError.dfy file "fixes" the issue.

What type of operating system are you experiencing the problem on?

Windows

Pireax avatar Aug 23 '23 22:08 Pireax

I could reproduce this

keyboardDrummer avatar Apr 24 '24 14:04 keyboardDrummer