Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type checking bug when masking polymorphic effects #509

Open
anfelor opened this issue Apr 24, 2024 · 0 comments
Open

Type checking bug when masking polymorphic effects #509

anfelor opened this issue Apr 24, 2024 · 0 comments
Labels

Comments

@anfelor
Copy link
Collaborator

anfelor commented Apr 24, 2024

Consider the following program using effect polymorphism (due to @thwfhk):

effect reader<s>
  fun ask() : s

fun test( p : () -> <reader<int>, reader<int>|e> a ) : e a
  with handler
    fun ask() 100
  with handler
    fun ask() 42
  p()

pub fun main(): console ()
  with test
  println(mask<reader<int>>(ask) : int)

As expected, it completes with output 100 and hovering over the call to ask we get the correct instantiation fun ask : () -> <reader<int>,console/console> int.

However, Koka surprisingly also accepts:

pub fun main(): console ()
  with test
  println(mask<reader<int>>(ask()) : int) // notice the call to ask

Hovering over ask again, we get the wrong instantiation fun ask : () -> <reader<() -> <console/console,reader<int>> int>|_e> (() -> <console/console,reader<int>> int). This program is accepted by the type checker but segfaults at runtime.

@TimWhiting TimWhiting added the bug label May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants