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

No supertype allowed in handler return #604

Open marzipankaiser opened 2 months ago

marzipankaiser commented 2 months ago

The following program gives the annotated error:

interface Done {
  def done(): Nothing
}

def main() = {
  try {
    do done()
  } with Done {
    def done() = ()   // Error: Expected Nothing but got Unit.
  }
}

Is this the behaviour we want?

Note that this also disallows, e.g., a hole instead of do done().

b-studios commented 2 months ago

What would you expect, otherwise? The answer type of the handler is Nothing unless you upcast it there.

We could of course compute the join of the different handlers and the answer type.