-
Notifications
You must be signed in to change notification settings - Fork 194
Open
Milestone
Description
Description:
When I write the following code:
fun test(action)
var i := 0
val res = action()
resI get the following compiler error:
abstract type(s) escape(s) into the context
term : var i := 0
val res = action()
res
inferred type: () -> <local<$h>|_e> _a
hint : give a higher-rank type annotation to a function parameter?So I try to fix it by adding a type annotation:
fun test(action : () -> e a) : e a
var i := 0
val res = action()
resHowever, this gives a different error:
effects do not match
context : var i := 0
val res = action()
res
term : val res = action()
res
inferred effect: $e
expected effect: <local<_h>|_e1>Surprisingly, if I inline the call to action() without a val binding, the code compiles and runs fine:
fun test(action)
var i := 0
action()This behavior is confusing.
Expected behavior:
The presence or absence of a val binding for the result of action() should not affect whether type or effect inference succeeds. The two forms should be equivalent from the perspective of effects and region scoping.
Environment:
- Koka version: v3.1.3-alpha14
- OS: Windows 11
Minimal reproduction:
fun test(action)
var i := 0
val res = action()
resThanks!
Metadata
Metadata
Assignees
Labels
No labels