effekt-lang / effekt-lang/effekt
Order-dependent overload resolution wrongly claims type escapes
- Dominant language
- Scala
- Stars
- 469
- Forks
- 41
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 23
Description
From https://github.com/effekt-lang/effekt-website/pull/124, minimized by @timsueberkrueb ([original here](https://effekt-lang.org/playground.html?playground=bZAxa8MwFIR3%2FYobLTAFaxSoQyFDwVvoZEwRttwIZMmVNKSU%2FPc%2Bu3aiIZPg3b3Tdy%2BaIcQRbRh0tsF3bV%2FZUeLd5xpez0binKP1X5yx%2FLMYnMNsDjN%2BGXC62pTTuudkGcPZjbHRTLB%2BstfTd9c2NVpBtqb0NX0NJ8qJ6LnEWwgOiuLJvho4Zp2Hy%2FYjMOhkUB0rBEyeT07xj4lYJxzqFaRCKXoE7e5MZlk24kQfE35XtiKgi4lUvCwj8eFthtoBXHqZQjT6TrQz%2FR%2Bjchzaj6AGastaMSr%2B3PiQbsfFZm19RQoJfw%3D%3D&repl=bWFpbigp))
---
I think this is related to #996, cc @marzipankaiser
The following program ([playground link](https://effekt-lang.org/playground.html?playground=jVC7asQwEOz9FePOgiOHXRocSCCdu1wq40LYe7FBkRRJ4WIO%2F3tWUQIqrrhGj92dmZ1xNBk3ozeTDKvRQz9WogibJbyaD%2Fov44qX79UHP%2FQ0VqrN5mkU2HE8guIA6bBKVcx0Bn0OfX1A3zCgzhH1eIBq8kozihbPxih0CO6LioL5gtvgL9LaVb8jLATekxzMOX48IVxMmYTktAwnVmF9ZuWTf4JXllOkb3FC94g3vQbsbbo7sMscK51r8eSc3O7DJrC1MS%2Fl%2F1TzxNjjQo5yl9FkYigA5R%2BiNq78BibJhlLClRKQeub4KpU4RFyhEjHjsixvzf%2F2ubH%2FAA%3D%3D&repl=KCk%3D)) doesn't work correctly:
```scala
record Location[L]()
type SomeLocation { Exists[Le](l: Location[Le]) } // existential
def eq[L1, L2](l1: Location[L1], l2: Location[L2]): Bool = true
// try swapping the order of these two!
def each[T](list: List[T]) { action: T => Unit }: Unit = ()
def each[T](arr: Array[T]) { action: T => Unit }: Unit = ()
def epp[L](ls: List[SomeLocation], here: Location[L]): Unit =
ls.each {
case Exists(l) and eq(l, here) => () // !!!
case Exists(l) => ()
}
```
In this order of `each` declarations, the call-site of `eq` (`!!!`) shows `Type Le escapes through type Le inferred as first type argument.`
If you flip their order around (or specify via namespaces / renaming), the problem magically resolves itself.
Our hypothesis is that the current overload resolution backtracks badly (again, as in #996).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.