From 0a4842dbb65ae2f229b0b1d342db4766e2053b9f Mon Sep 17 00:00:00 2001 From: Ilya Smagin Date: Wed, 26 Sep 2018 14:59:53 +0300 Subject: [PATCH] NODE-1182: allow scope leak --- .../test/scala/com/wavesplatform/lang/IntegrationTest.scala | 4 ++-- .../com/wavesplatform/lang/v1/evaluator/EvaluatorV1.scala | 4 ++-- .../scala/com/wavesplatform/lang/v1/task/TaskMFunctions.scala | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lang/jvm/src/test/scala/com/wavesplatform/lang/IntegrationTest.scala b/lang/jvm/src/test/scala/com/wavesplatform/lang/IntegrationTest.scala index 42a6550f42a..2031e3bbafe 100755 --- a/lang/jvm/src/test/scala/com/wavesplatform/lang/IntegrationTest.scala +++ b/lang/jvm/src/test/scala/com/wavesplatform/lang/IntegrationTest.scala @@ -281,7 +281,7 @@ class IntegrationTest extends PropSpec with PropertyChecks with ScriptGen with M eval[Long](script, Some(pointAInstance)) shouldBe Right(5) } - property("context won't change after execution of a user function") { + ignore("context won't change after execution of a user function") { val doubleFst = UserFunction("ID", LONG, "x" -> LONG) { FUNCTION_CALL(PureContext.sumLong.header, List(REF("x"), REF("x"))) } @@ -299,7 +299,7 @@ class IntegrationTest extends PropSpec with PropertyChecks with ScriptGen with M ev[Long](context, expr) shouldBe Right(2003l) } - property("context won't change after execution of an inner block") { + ignore("context won't change after execution of an inner block") { val context = Monoid.combine( PureContext.evalContext, EvaluationContext( diff --git a/lang/shared/src/main/scala/com/wavesplatform/lang/v1/evaluator/EvaluatorV1.scala b/lang/shared/src/main/scala/com/wavesplatform/lang/v1/evaluator/EvaluatorV1.scala index 817209c3449..977358ca195 100644 --- a/lang/shared/src/main/scala/com/wavesplatform/lang/v1/evaluator/EvaluatorV1.scala +++ b/lang/shared/src/main/scala/com/wavesplatform/lang/v1/evaluator/EvaluatorV1.scala @@ -22,7 +22,7 @@ object EvaluatorV1 extends ExprEvaluator { ctx <- get[LoggedEvaluationContext, ExecutionError] blockEvaluation = evalExpr(let.value) lazyBlock = LazyVal(blockEvaluation.ter(ctx), ctx.l(let.name)) - result <- local { + result <- id { modify[LoggedEvaluationContext, ExecutionError](lets.modify(_)(_.updated(let.name, lazyBlock))) .flatMap(_ => evalExpr(inner)) } @@ -61,7 +61,7 @@ object EvaluatorV1 extends ExprEvaluator { val letDefsWithArgs = args.zip(func.signature.args).foldLeft(ctx.ec.letDefs) { case (r, (argValue, (argName, _))) => r + (argName -> LazyVal(argValue.pure[TrampolinedExecResult], ctx.l("(arg)" + argName))) } - local { + id { set(LoggedEvaluationContext.Lenses.lets.set(ctx)(letDefsWithArgs)).flatMap(_ => evalExpr(func.ev)) } } diff --git a/lang/shared/src/main/scala/com/wavesplatform/lang/v1/task/TaskMFunctions.scala b/lang/shared/src/main/scala/com/wavesplatform/lang/v1/task/TaskMFunctions.scala index 309dd9aeaa7..76f08bbd0a3 100644 --- a/lang/shared/src/main/scala/com/wavesplatform/lang/v1/task/TaskMFunctions.scala +++ b/lang/shared/src/main/scala/com/wavesplatform/lang/v1/task/TaskMFunctions.scala @@ -26,6 +26,8 @@ trait TaskMFunctions { })) } + def id[S, E, A](fa: TaskM[S, E, A]): TaskM[S, E, A] = fa + def inspect[S, E, A](f: S => A): TaskM[S, E, A] = get[S, E].map(f) def inspectFlat[S, E, A](f: S => TaskM[S, E, A]): TaskM[S, E, A] = get[S, E].flatMap(f)