Skip to content

Commit

Permalink
Add mising if test for BitVectorType
Browse files Browse the repository at this point in the history
closes #39
  • Loading branch information
qunyanm committed Oct 6, 2016
1 parent cad9ce6 commit 3f899b9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Source/Dafny/Translator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10147,6 +10147,8 @@ bool CompatibleDecreasesTypes(Type t, Type u) {
return u is MapType && ((MapType)t).Finite == ((MapType)u).Finite;
} else if (t is ArrowType) {
return u is ArrowType;
} else if (t is BitvectorType) {
return u is BitvectorType;
} else {
Contract.Assert(t.IsTypeParameter || t.IsInternalTypeSynonym);
return false; // don't consider any type parameters to be the same (since we have no comparison function for them anyway)
Expand Down Expand Up @@ -10263,6 +10265,12 @@ void ComputeLessEq(IToken tok, Type ty0, Type ty1, Bpl.Expr e0, Bpl.Expr e1, out
less = Bpl.Expr.False;
atmost = Bpl.Expr.False;

} else if (ty0 is BitvectorType) {
BitvectorType bv = (BitvectorType)ty0;
eq = Bpl.Expr.Eq(e0, e1);
less = FunctionCall(tok, "lt_bv" + bv.Width, Bpl.Type.Bool, e0, e1);
atmost = FunctionCall(tok, "ge_bv" + bv.Width, Bpl.Type.Bool, e0, e1);

} else {
// reference type
Contract.Assert(ty0.IsRefType); // otherwise, unexpected type
Expand Down
8 changes: 8 additions & 0 deletions Test/dafny4/git-issue39.dfy
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// RUN: %dafny /compile:0 "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

function BitsAsInt(b:bv32): int
ensures 0 <= BitsAsInt(b) < 0x1_0000_0000
{
b as int
}
2 changes: 2 additions & 0 deletions Test/dafny4/git-issue39.dfy.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

Dafny program verifier finished with 1 verified, 0 errors

0 comments on commit 3f899b9

Please sign in to comment.