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
This commit is contained in:
Remy 2021-10-11 18:16:05 +02:00 committed by GitHub
parent d8651fae32
commit 4af98a63a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
},
)
) { _ =>