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

Supplying type for _ in pattern causes crash #3923

Closed
RustanLeino opened this issue Apr 29, 2023 · 1 comment · Fixed by #3909
Closed

Supplying type for _ in pattern causes crash #3923

RustanLeino opened this issue Apr 29, 2023 · 1 comment · Fixed by #3909
Assignees
Labels
kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: resolver Resolution and typechecking

Comments

@RustanLeino
Copy link
Collaborator

Dafny version

4.0.0

Code to produce this issue

datatype Fruit = Apple(u: int) | Pear(t: int)

method Jkl(fruit: Fruit)
{
  match fruit
  case Apple(_: int) => // supplying ": int" here causes a crash
    DoSomething();
  case _  =>
}

method DoSomething() {
}

Command to run and resulting output

% dafny test.dfy
Unhandled exception. System.AggregateException: One or more errors occurred. (Value cannot be null. (Parameter 'key'))
 ---> System.ArgumentNullException: Value cannot be null. (Parameter 'key')
   at System.Collections.Generic.Dictionary`2.FindValue(TKey key)
   at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
   at Microsoft.Dafny.Translator.CheckDefiniteAssignment(IdentifierExpr expr, BoogieStmtListBuilder builder)
   at Microsoft.Dafny.Translator.CheckWellformedWithResult(Expression expr, WFOptions options, Expr result, Type resultType, List`1 locals, BoogieStmtListBuilder builder, ExpressionTranslator etran)
   at Microsoft.Dafny.Translator.TrStmt(Statement stmt, BoogieStmtListBuilder builder, List`1 locals, ExpressionTranslator etran)

What happened?

As can be inspected using /rprint, the desugaring of the match statement introduces a variable _v00, but omits its declaration. This causes a crash downstream in the Dafny pipeline.

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

Mac

@RustanLeino RustanLeino added kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: resolver Resolution and typechecking labels Apr 29, 2023
@RustanLeino RustanLeino self-assigned this Apr 29, 2023
@RustanLeino
Copy link
Collaborator Author

Note, changing _: int to just _ or to x: int works around the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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