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

Underspecified subset-type type arguments causes crash #3921

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

Underspecified subset-type type arguments causes crash #3921

RustanLeino opened this issue Apr 28, 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

type SubsetType<X> = x: int | true

method M() {
  var s: SubsetType; // type parameter underspecified
  s := 3;
}

Command to run and resulting output

% dafny test.dfy
Unhandled exception. System.AggregateException: One or more errors occurred. (Exception of type 'cce+UnreachableException' was thrown.)
 ---> cce+UnreachableException: Exception of type 'cce+UnreachableException' was thrown.
   at Microsoft.Dafny.Translator.TypeToTy(Type type)
   at System.Collections.Generic.List`1.ConvertAll[TOutput](Converter`2 converter)
   at Microsoft.Dafny.Translator.TypeToTy(Type type)
   at Microsoft.Dafny.Translator.MkIs(Expr x, Type t)
   at Microsoft.Dafny.Translator.GetSubrangeCheck(Expr bSource, Type sourceType, Type targetType, ProofObligationDescription& desc, String errorMessagePrefix)
   at Microsoft.Dafny.Translator.TrAssignmentRhs(IToken tok, IdentifierExpr bGivenLhs, IVariable lhsVar, Type lhsType, AssignmentRhs rhs, Type rhsTypeConstraint, BoogieStmtListBuilder builder, List`1 locals, ExpressionTranslator etran)
...

What happened?

Instead of giving an error that the type of s is underspecified, Dafny (proceeds to the verifier and) crashes.

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 28, 2023
@RustanLeino RustanLeino self-assigned this Apr 28, 2023
@RustanLeino
Copy link
Collaborator Author

Here's a similar test case that fails in the same way:

type SubsetType<X> = x: int | true
datatype Record<U> = Record(SubsetType<U>)

method P(r: Record<real>) {
  match r
  case Record(s: SubsetType) => // type argument underspecified
}

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