From 4af98a63a231b7ae038b8b38a73404b9e4bef01e Mon Sep 17 00:00:00 2001 From: Remy Date: Mon, 11 Oct 2021 18:16:05 +0200 Subject: [PATCH] LF: clarify compilation of choice body. (#11195) * LF: clarify compilation of choice Body. This is a purely cosmetic choice. We move up the intro of the choice arg binder to make it clear it affect the compilation of every expression in the body of a choices ( namely controllers, observers, and update expression). CHANGELOG_BEGIN CHANGELOG_END * formatting --- .../digitalasset/daml/lf/speedy/Compiler.scala | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Compiler.scala b/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Compiler.scala index 80ab466b045..2ed326844d2 100644 --- a/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Compiler.scala +++ b/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Compiler.scala @@ -991,24 +991,22 @@ private[lf] final class Compiler( cidPos: Position, mbKey: Option[Position], // defined for byKey operation tokenPos: Position, - ) = { + ) = withEnv { _ => let( SBUFetch( tmplId )(svar(cidPos), mbKey.fold(SEValue.None: SExpr)(pos => SBSome(svar(pos)))) ) { tmplArgPos => addExprVar(tmpl.param, tmplArgPos) + addExprVar(choice.argBinder._1, choiceArgPos) let( SBUBeginExercise(tmplId, choice.name, choice.consuming, byKey = mbKey.isDefined)( svar(choiceArgPos), - svar(cidPos), { - addExprVar(choice.argBinder._1, choiceArgPos) - compile(choice.controllers) - }, { - choice.choiceObservers match { - case Some(observers) => compile(observers) - case None => SEValue.EmptyList - } + svar(cidPos), + compile(choice.controllers), + choice.choiceObservers match { + case Some(observers) => compile(observers) + case None => SEValue.EmptyList }, ) ) { _ =>