this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

internal/core/adt: do not side-effect argument state to result state

Currently the call logic updates the `state` variable depending on
argument logic. Intuitively this seems wrong: we shouldn't need to
change the interpretation of the result of a function depending on
whether its arguments are concrete or not.

This doesn't seem to change any user-visible behavior: I wasn't able to
find any existing stdlib functions whose behavior changed as a result,
probably because the evaluation only applies at the top level and there
are no stdlib functions that can be provoked into returning a
disjunction as the top level result value.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I058d99940ba65e0488af1b6b85efce5541987543
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1232475
Reviewed-by: Marcel van Lohuizen <mpvl@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+11 -15
+11 -15
internal/core/adt/expr.go
··· 1509 1509 c.errs = nil 1510 1510 // XXX: XXX: clear id.closeContext per argument and remove from runTask? 1511 1511 1512 - runMode := state.mode 1513 - cond := state.condition 1514 1512 var expr Value 1515 1513 if builtin.NonConcrete { 1516 - state = Flags{ 1514 + expr = c.evalState(a, Flags{ 1517 1515 status: state.status, 1518 - condition: cond, 1519 - mode: runMode, 1520 - } 1521 - expr = c.evalState(a, state) 1516 + condition: state.condition, 1517 + mode: state.mode, 1518 + }) 1522 1519 } else { 1523 - cond |= fieldSetKnown | concreteKnown 1520 + state := Flags{ 1521 + status: state.status, 1522 + condition: state.condition | fieldSetKnown | concreteKnown, 1523 + mode: state.mode, 1524 + } 1524 1525 // Be sure to process disjunctions at the very least when 1525 1526 // finalizing. Requiring disjunctions earlier may lead to too eager 1526 1527 // evaluation. 1527 1528 // 1528 1529 // TODO: Ideally we would always add this flag regardless of mode. 1529 - if runMode == finalize { 1530 - cond |= disjunctionTask 1531 - } 1532 - state = Flags{ 1533 - status: state.status, 1534 - condition: cond, 1535 - mode: runMode, 1530 + if state.mode == finalize { 1531 + state.condition |= disjunctionTask 1536 1532 } 1537 1533 expr = c.value(a, state) 1538 1534 }