Closed samuelchassot closed 3 weeks ago
indeed, when printing the trees, we get:
[ Debug ] @final
[ Debug ] def test[C](r: Regex[C]): Set[C] = Set(Cons[Regex[C]](r, Nil[Regex[C]]()))
So the expansion of type Zipper[C]
is wrong. I need to investigate why.
As the tree is wrong before the preprocessing phase, I'm guessing the problem comes from the extraction.
The bug comes from the extraction, in CodeExtract.scala https://github.com/epfl-lara/stainless/blob/00103687f10e377dc29f4eb36eceabbf8e2f92fc/frontends/dotty/src/main/scala/stainless/frontends/dotc/CodeExtraction.scala#L2364
case AppliedType(tr: TypeRef, Seq(tp)) if isSetSym(tr.symbol) =>
xt.SetType(extractType(tp))
in the isSetSym
, the type aliases are resolved, so the type Zipper[C]
is resolved to be a set symbol. However, here tp
is C
(in the case of type Zipper[C] = Set[List[Regex[C]]]
, so when extracted it is C
instead of List[Regex[C]]
. So it has to dealias types at that stage. I'm working on a fix.
This bug appears also with other types treated on their own, like Map
:
type TestType[A] = Map[Int, List[A]]
val t: TestType[Int] = Map(1 -> List(1, 2, 3), 2 -> List(4, 5, 6))
I was working on the Zipper for Regex implementation, and the well-formedness check didn't pass so I minimised the example and here it is:
And here is the error:
When happening in the real project, the error is far more complicated and the type of the function found is
<untyped>
but I presume this is the same bug.Apparently it is expecting
Set[C]
instead ofSet[Context[C]]
i.e.,Set[List[Regex[C]]]