Skip to content
Snippets Groups Projects
Commit c6ec9578 authored by Regis Blanc's avatar Regis Blanc
Browse files

xlang does not lift code outside of lambdas

parent cbfa87da
Branches
Tags
No related merge requests found
......@@ -304,6 +304,11 @@ object ImperativeCodeElimination extends UnitPhase[Program] {
}
}
//TODO: handle vars in scope, just like LetDef
case ld@Lambda(params, body) =>
val (bodyVal, bodyScope, bodyFun) = toFunction(body)
(Lambda(params, bodyScope(bodyVal)).copiedFrom(ld), (e: Expr) => e, Map())
case c @ Choose(b) =>
//Recall that Choose cannot mutate variables from the scope
(c, (b2: Expr) => b2, Map())
......
object Lambda1 {
def test(): Int = {
val x = 2
val cl = ((y: Int) => {
var z = y
z = z + x
z
})
cl(4)
} ensuring(_ == 6)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment