Skip to content

Commit 0fc6017

Browse files
authored
Disallow asserting expressions in axioms (#858)
1 parent be1716f commit 0fc6017

3 files changed

Lines changed: 19 additions & 0 deletions

File tree

src/main/scala/viper/silver/ast/Program.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ sealed trait DomainAxiom extends DomainMember {
568568
(if(!Consistency.noResult(exp)) Seq(ConsistencyError("Axioms can never contain result variables.", exp.pos)) else Seq()) ++
569569
(if(!Consistency.noOld(exp)) Seq(ConsistencyError("Axioms can never contain old expressions.", exp.pos)) else Seq()) ++
570570
(if(!Consistency.noLocationAccesses(exp)) Seq(ConsistencyError("Axioms can never contain location accesses.", exp.pos)) else Seq()) ++
571+
(if(!Consistency.noAsserting(exp)) Seq(ConsistencyError("Axioms can never contain asserting expressions.", exp.pos)) else Seq()) ++
571572
(if(!(exp isSubtype Bool)) Seq(ConsistencyError("Axioms must be of Bool type", exp.pos)) else Seq()) ++
572573
Consistency.checkPure(exp)
573574

src/main/scala/viper/silver/ast/utility/Consistency.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ object Consistency {
9090
/** Returns true if the given node contains no location accesses. */
9191
def noLocationAccesses(n: Node) = !n.existsDefined { case _: LocationAccess => }
9292

93+
/** Returns true if the given node contains no asserting expressions. */
94+
def noAsserting(n: Node) = !n.existsDefined { case _: Asserting => }
95+
9396
/** Returns true if the given node contains no accessibility predicates (unfolding predicates is
9497
* allowed) and no magic wands (applying wands is allowed).
9598
*/
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Any copyright is dedicated to the Public Domain.
2+
// http://creativecommons.org/publicdomain/zero/1.0/
3+
4+
5+
domain foo {
6+
function bar(): Bool
7+
8+
axiom {
9+
//:: ExpectedOutput(consistency.error)
10+
asserting (true) in true
11+
}
12+
}
13+
14+
function baz(): Int
15+
requires bar()

0 commit comments

Comments
 (0)