effekt icon indicating copy to clipboard operation
effekt copied to clipboard

Wrong effect inferred for effectful `while` header

Open marzipankaiser opened this issue 5 months ago • 2 comments

The following program compiles without typer errors:

interface Foo { def foo(): Unit }

def bar(): Bool / Foo = {
  do foo()
  false
}

def fooo() = {
  while(bar() is true) {
      ()
    }
}

def main() = {
  fooo()
}

but crashes at runtime (in JS), because there is no handler for the do foo in the loop header. The type of fooo is shown (at least via LSP) as def fooo(): Unit / {}.

Adding a handler in main generates a warning that the handler is unused (but runs fine).

marzipankaiser avatar Sep 23 '24 20:09 marzipankaiser