diff --git a/src/main/java/wyboogie/tasks/BoogieCompiler.java b/src/main/java/wyboogie/tasks/BoogieCompiler.java index e47f966..c3fbed7 100644 --- a/src/main/java/wyboogie/tasks/BoogieCompiler.java +++ b/src/main/java/wyboogie/tasks/BoogieCompiler.java @@ -1657,7 +1657,12 @@ public Expr constructBitwiseShiftRight(WyilFile.Expr.BitwiseShiftRight expr, Exp @Override public Expr constructCast(WyilFile.Expr.Cast expr, Expr operand) { - return cast(expr.getType(), expr.getOperand().getType(), operand); + Expr e = cast(expr.getType(), expr.getOperand().getType(), operand); + // TODO: this is a bit of a kludge. The generate cast uses attributes from the + // operand, where as we want to have the attribute refer to the cast itself. A + // better solution would be to add an extra argument to cast. + e.getAttributes()[0] = ATTRIBUTE(expr); + return e; } @Override @@ -3182,7 +3187,7 @@ private List constructTypeConstraints(Tuple constructRemainder(Expr.Remainder expr, List constructInvoke(Expr.Invoke expr, List> preconditions) { + Syntactic.Item wyItem = expr.getAttribute(Syntactic.Item.class); List rs = flattern(preconditions, l -> l); // Special case! if (expr.getName().equals("Array#Generator")) { Expr len = expr.getArguments().get(1); rs.add(ASSERT(LTEQ(CONST(0), len, len.getAttributes()), ATTRIBUTE(WyilFile.STATIC_NEGATIVE_LENGTH_FAILURE))); + } else if(wyItem instanceof WyilFile.Expr.Cast) { + WyilFile.Expr.Cast c = (WyilFile.Expr.Cast) wyItem; + Expr arg = bc.reconstructExpression(c.getOperand()); + //Expr arg = expr.getArguments().get(0); + Expr.Logical test = bc.constructTypeTest(c.getType(), c.getOperand().getType(), arg, BoogieCompiler.HEAP, wyItem); + rs.add(ASSERT(test, ATTRIBUTE(WyilFile.STATIC_TYPEINVARIANT_FAILURE))); } return rs; } diff --git a/src/test/java/wyboogie/WhileyCompilerTests.java b/src/test/java/wyboogie/WhileyCompilerTests.java index d9d31af..be3c408 100644 --- a/src/test/java/wyboogie/WhileyCompilerTests.java +++ b/src/test/java/wyboogie/WhileyCompilerTests.java @@ -112,7 +112,7 @@ public void debugTests(Trie path) throws IOException { // Here we enumerate all available test cases. private static Stream debugFiles() throws IOException { - return readTestFiles(WHILEY_SRC_DIR, in(190,1163,1164,1418)); + return readTestFiles(WHILEY_SRC_DIR, in(125,809)); // return readTestFiles(WHILEY_SRC_DIR, atleast(99999)); } diff --git a/tests/000920.test b/tests/000920.test index 2200013..65835e2 100644 --- a/tests/000920.test +++ b/tests/000920.test @@ -16,4 +16,4 @@ public export method test(): assume f() == 0 --- E702 main.whiley 9,11:19 -E717 main.whiley 9,4:19 +E718 main.whiley 9,11:19 diff --git a/tests/001250.test b/tests/001250.test index b39000f..a32f4cd 100644 --- a/tests/001250.test +++ b/tests/001250.test @@ -18,4 +18,4 @@ public export method test(): f((pos) 1) --- E702 main.whiley 10,10:16 -E716 main.whiley 10,8:17 +E718 main.whiley 10,10:16 diff --git a/tests/001269.test b/tests/001269.test index b60e570..5cf3457 100644 --- a/tests/001269.test +++ b/tests/001269.test @@ -15,4 +15,4 @@ public export method test(): g(-1) --- E702 main.whiley 7,11:17 -E717 main.whiley 7,4:17 +E718 main.whiley 7,11:17 diff --git a/tests/001292.test b/tests/001292.test index c1c7366..ca0009b 100644 --- a/tests/001292.test +++ b/tests/001292.test @@ -17,4 +17,4 @@ public export method test(): assume g(0) == 0 --- E702 main.whiley 9,13:23 -E716 main.whiley 9,11:24 +E718 main.whiley 9,13:23 diff --git a/tests/001293.test b/tests/001293.test index 24f3210..b1f272c 100644 --- a/tests/001293.test +++ b/tests/001293.test @@ -22,4 +22,4 @@ public export method test(): assume f(0) == 0 --- E702 main.whiley 14,11:20 -E717 main.whiley 14,4:20 +E718 main.whiley 14,11:20