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: Compilation of subset types constrained by type parameter #3893

Merged
merged 15 commits into from
May 4, 2023
Prev Previous commit
Next Next commit
fix: Improve Subrange verification to reduce a completeness issue
Fixes #3891
  • Loading branch information
RustanLeino committed Apr 21, 2023
commit d2dca994e2827887018d7b80c7359784d2b042e9
11 changes: 8 additions & 3 deletions Source/DafnyCore/Verifier/Translator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7108,7 +7108,7 @@ class BoilerplateTriple { // a triple that is now a quintuple
}
}

public Bpl.Expr CondApplyBox(IToken tok, Bpl.Expr e, Type fromType, Type toType) {
public Bpl.Expr CondApplyBox(Bpl.IToken tok, Bpl.Expr e, Type fromType, Type toType) {
Contract.Requires(tok != null);
Contract.Requires(e != null);
Contract.Requires(fromType != null);
Expand Down Expand Up @@ -7136,7 +7136,7 @@ class BoilerplateTriple { // a triple that is now a quintuple
}
}

public Bpl.Expr BoxIfNecessary(IToken tok, Bpl.Expr e, Type fromType) {
public Bpl.Expr BoxIfNecessary(Bpl.IToken tok, Bpl.Expr e, Type fromType) {
Contract.Requires(tok != null);
Contract.Requires(e != null);
Contract.Requires(fromType != null);
Expand Down Expand Up @@ -9051,8 +9051,13 @@ public ForceCheckToken(IToken tok)
return null;
}
targetType = targetType.NormalizeExpandKeepConstraints();
var cre = MkIs(bSource, targetType);
var udt = targetType as UserDefinedType;
Bpl.Expr cre;
if (udt?.ResolvedClass is RedirectingTypeDecl redirectingTypeDecl && ModeledAsBoxType(redirectingTypeDecl.Var.Type)) {
cre = MkIs(BoxIfNecessary(bSource.tok, bSource, sourceType), TypeToTy(targetType), true);
} else {
cre = MkIs(bSource, targetType);
}
if (udt != null && udt.IsRefType) {
var s = sourceType.NormalizeExpandKeepConstraints();
var certain = false;
Expand Down