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

Crash in ModuleQualifiedId.Set #2108

Closed
cpitclaudel opened this issue May 7, 2022 · 0 comments · Fixed by #2993
Closed

Crash in ModuleQualifiedId.Set #2108

cpitclaudel opened this issue May 7, 2022 · 0 comments · Fixed by #2993
Labels
crash Dafny crashes on this input, or generates malformed code that can not be executed kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: resolver Resolution and typechecking

Comments

@cpitclaudel
Copy link
Member

Input:

module M0.M1.Base {}

module M0.M2 {
  import M1.Base

  module Derived refines Base {
  }
}

Output:

Unhandled exception. System.AggregateException: One or more errors occurred. (Unable to cast object of type 'Microsoft.Dafny.AliasModuleDecl' to type 'Microsoft.Dafny.LiteralModuleDecl'.)
 ---> System.InvalidCastException: Unable to cast object of type 'Microsoft.Dafny.AliasModuleDecl' to type 'Microsoft.Dafny.LiteralModuleDecl'.
   at Microsoft.Dafny.ModuleQualifiedId.Set(ModuleDecl m) in C:\dafny\Source\Dafny\AST\DafnyAst.cs:line 3943
   at Microsoft.Dafny.Resolver.ResolveProgram(Program prog) in C:\dafny\Source\Dafny\Resolver.cs:line 492
   at Microsoft.Dafny.Main.Resolve(Program program, ErrorReporter reporter) in C:\dafny\Source\Dafny\DafnyMain.cs:line 162
   at Microsoft.Dafny.Main.ParseCheck(IList`1 files, String programName, ErrorReporter reporter, Program& program) in C:\dafny\Source\Dafny\DafnyMain.cs:line 113
   at Microsoft.Dafny.DafnyDriver.ProcessFiles(IList`1 dafnyFiles, ReadOnlyCollection`1 otherFileNames, ErrorReporter reporter, Boolean lookForSnapshots, String programId) in C:\dafny\Source\DafnyDriver\DafnyDriver.cs:line 249
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()
   at Microsoft.Dafny.DafnyDriver.ThreadMain(String[] args) in C:\dafny\Source\DafnyDriver\DafnyDriver.cs:line 67
   at Microsoft.Dafny.DafnyDriver.<>c__DisplayClass6_0.<Main>b__0() in C:\dafny\Source\DafnyDriver\DafnyDriver.cs:line 47
   at System.Threading.Thread.StartCallback()
@cpitclaudel cpitclaudel added kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: resolver Resolution and typechecking crash Dafny crashes on this input, or generates malformed code that can not be executed labels May 7, 2022
MikaelMayer added a commit that referenced this issue Nov 4, 2022
MikaelMayer added a commit that referenced this issue Nov 7, 2022
…orts (#2993)

This PR fixes #2108
Basically, we were trying to call ModuleQualifiedId.Set() on something
else than a LiteralModuleDecl, and it happened it was an
AliasModuleDecl. Since we were only interested by the underlying
ModuleDefinition, I added a case to ensure it does not crash for
AliasModuleDecl

<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
crash Dafny crashes on this input, or generates malformed code that can not be executed kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: resolver Resolution and typechecking
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant