effekt-lang / effekt

A language with lexical effect handlers and lightweight effect polymorphism
https://effekt-lang.org
MIT License
334 stars 24 forks source link

Fix PolymorphismBoxing for more complex uses of interfaces and effect handlers #575

Closed marzipankaiser closed 2 months ago

marzipankaiser commented 2 months ago

This fixes the program mentioned by @marvinborner in #568.

In order to do this, this also fixes #574 (thats just 257c07a, if we'd want to cherry-pick)

cc @phischu

marzipankaiser commented 2 months ago

This now just fails one previous test case for me locally, which seems to be related to #574 (this now erases the non-declared arguments when coercing in this test case).

marvinborner commented 2 months ago

examples/pos/parametrized.effekt now fails with "Wrong number of type arguments". Previously it just segfaulted.

Stacktrace:

[error] java.lang.AssertionError: assertion failed: Wrong number of type arguments
[error]     at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
[error]     at effekt.core.Type$.instantiate(Type.scala:100)
[error]     at effekt.core.Type$.inferType(Type.scala:166)
[error]     at effekt.core.Stmt.<init>(Tree.scala:314)
[error]     at effekt.core.Stmt$App.<init>(Tree.scala:291)
[error]     at effekt.core.Stmt$App$.apply(Tree.scala:291)
[error]     at effekt.core.PolymorphismBoxing$$anon$5.apply(PolymorphismBoxing.scala:551)
[error]     at effekt.core.PolymorphismBoxing$$anon$5.apply(PolymorphismBoxing.scala:542)
[error]     at effekt.core.PolymorphismBoxing$.transform(PolymorphismBoxing.scala:227)
[error]     at effekt.core.PolymorphismBoxing$.transform(PolymorphismBoxing.scala:289)
[error]     at effekt.core.PolymorphismBoxing$.transform(PolymorphismBoxing.scala:281)
[error]     at effekt.core.PolymorphismBoxing$.transform(PolymorphismBoxing.scala:281)
[error]     at effekt.core.PolymorphismBoxing$.transform(PolymorphismBoxing.scala:212)
[error]     at effekt.core.PolymorphismBoxing$.transform(PolymorphismBoxing.scala:217)
[error]     at effekt.core.PolymorphismBoxing$.transform(PolymorphismBoxing.scala:195)
[error]     at effekt.core.PolymorphismBoxing$.transform$$anonfun$3(PolymorphismBoxing.scala:155)
[error]     at scala.collection.immutable.List.flatMap(List.scala:293)
[error]     at effekt.core.PolymorphismBoxing$.transform(PolymorphismBoxing.scala:155)
[error]     at effekt.core.PolymorphismBoxing$.$anonfun$4(PolymorphismBoxing.scala:148)
[error]     at effekt.util.Timers.timed(Timer.scala:39)
[error]     at effekt.util.Timers.timed$(Timer.scala:12)
[error]     at effekt.context.Context.timed(Context.scala:40)
[error]     at effekt.core.PolymorphismBoxing$.run(PolymorphismBoxing.scala:148)
[error]     at effekt.core.PolymorphismBoxing$.run(PolymorphismBoxing.scala:144)
[error]     at effekt.Phase$$anon$1.run$$anonfun$1(Phase.scala:51)
[error]     at scala.Option.flatMap(Option.scala:283)
...
marzipankaiser commented 2 months ago

@marvinborner Well, I guess this is better than a segfault ;) I will look into it.