-
Notifications
You must be signed in to change notification settings - Fork 40
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Effekt's optimizations are currently not semantics-preserving for the following program:
effect flip(): Bool
def all{prog: => Unit / {flip}} = {
try {
prog()
} with flip {
resume(true)
resume(false)
}
}
interface State[T] {
def get(): T
def set(x: T): Unit
}
interface allocate {
def fresh[T, R](init: T){k: {State[T]} => R}: R
}
def newRegion[T]{prog: {r: allocate} => T}: T = {
try {
prog{r}
} with r: allocate {
def fresh[T, R](init) = {
var x = init
def s = new State[T] {
def get() = x
def set(y) = {
x = y
}
}
resume{{k} => k{s}}
}
}
}
def main() = {
newRegion { {r} =>
all {
with def x = r.fresh(0)
if (do flip()) {
x.set(3)
} else {
}
println(x.get())
}
}
}with optimizations:
> effekt regions.effekt
3
0without optimizations:
> effekt regions.effekt --no-optimize
3
3Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working