Open drganam opened 1 year ago
@vkuncak @mario-bucev where would be a good place to add the full example? Bolts? Benchmarks?
It seems to stem from the compiler inferring something else than List[Int]
for the expression Nil()
.
The following adaptation works:
extension (l: List[Int])
def mapTr(f: Int => Int, acc: List[Int]): List[Int] =
l match
case Nil() => acc
case Cons(x, xs) => xs.mapTr(f, acc ++ (f(x) :: Nil[Int]()))
def MapEqMapTr(l: List[Int], f: Int => Int): Boolean = {
( Nil[Int]().map(f) == Nil[Int]().mapTr(f, Nil[Int]()) ) because {
Nil[Int]().map(f) ==| trivial |
Nil[Int]() ==| trivial |
Nil[Int]().mapTr(f, Nil[Int]())
}.qed
}.holds
which we could add in verification/valid
@mario-bucev Scala compiler inferring what it does, can Stainless give a better error message?
That would be neat however I do not see how we could proceed: should we emit a warning when we encounter any Any
or bounds inferred type? We could even error in such instances but that may invalidate the few legitimate cases there are. If, however, the Scala compiler has the information on whether a type was inferred or not, I think ruling out such cases would be a fair trade
The following (minimized) example:
results in the following error message: