Skip to content

Commit

Permalink
Merge branch 'main' into sam_reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelchassot authored Apr 12, 2024
2 parents dde7932 + 6ae9adc commit 82f6e41
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ trait EffectsAnalyzer extends oo.CachingPhase {
val specced = BodyWithSpecs(symbols.simplifyLets(fi.inlined))
specced.bodyOpt
.map(specced.wrapLets)
.forall(isExpressionFresh)
.forall(rec(_, bindings))

// other function invocations always return a fresh expression, by hypothesis (global assumption)
case (_: FunctionInvocation | _: ApplyLetRec | _: Application) => true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import stainless.lang._

object FreshExpr {
object FreshExpr1 {
case class C1(var c2: C2)
case class C2(var c3: C3)
case class C3(var bi: BigInt)
Expand Down
18 changes: 18 additions & 0 deletions frontends/benchmarks/imperative/valid/FreshExpr2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import stainless.lang._

object FreshExpr2 {

def iden(arr: Array[Int]) = arr

// Recursive functions must return fresh expression
def counting(i: Int): Array[Int] = {
require(0 <= i && i <= 10)
decreases(10 - i)
if (i < 10) {
counting(i + 1)
} else {
val b = Array.fill(0)(0)
iden(b) // This is a fresh expression
}
}
}

0 comments on commit 82f6e41

Please sign in to comment.