epfl-lara / stainless

Verification framework and tool for higher-order Scala programs
https://epfl-lara.github.io/stainless/
Apache License 2.0
349 stars 50 forks source link

Function not equal to its body when using extern annotations #1411

Open andreagilot-da opened 1 year ago

andreagilot-da commented 1 year ago

The following snippet does not verify although it is only asserting that foo is equal to its body:

  case class A(useless: BigInt) {
    @extern
    def map(f: (Unit) => (Unit, Unit)): A = this
  }

  def get(key: Unit): Option[Unit] = None[Unit]()

  def foo(m: A): A = {
    m.map {
      key =>
        val value = get(key) match {
          case None() => ()
          case Some(_) => ()
        }
        () -> value
    }
  }

  def fooEqualsItsBody(m: A): Unit = {
    assert(foo(m) == m.map {
      key =>
        val value = get(key) match {
          case None() => ()
          case Some(_) => ()
        }
        () -> value
    })
  }

The followings make the verification succeed:

mario-bucev commented 1 year ago

May be another instance of epfl-lara/inox#139