Open slewiskelly opened 1 month ago
The following yields the correct result, though I would expect a conflict:
import "list"
receipt: {
// Thanks for shopping at Big Kahuna Burger!
cheeseburger: 3.00
fries: 2.00
sprite: 1.00
total: list.Sum([for k, v in receipt {v}])
total: list.Sum([for k, v in receipt if k != "total" {v}])
}
Finally, the following yields a cycle error, as expected:
import "list"
receipt: {
// Thanks for shopping at Big Kahuna Burger.
cheeseburger: 3.00
fries: 2.00
sprite: 1.00
total: list.Sum([for k, v in receipt {v / 2}])
}
Thanks very much for the report, @slewiskelly.
The new evaluator does see this as a cycle (the following test passes, as of f5b905cec6d6):
env CUE_EXPERIMENT=evalv3
! exec cue export x.cue
cmp stderr stderr.golden
-- x.cue --
import "list"
receipt: {
// Thanks for shopping at Big Kahuna Burger!
cheeseburger: 3.00
fries: 2.00
sprite: 1.00
total: list.Sum([for _, v in receipt {v}])
}
-- stderr.golden --
receipt.3: structural cycle:
./x.cue:10:18
Sorry, I completely forgot to try with CUE_EXPERIMENT=evalv3
. As mentioned, this is identified as a cycle with that enabled:
$ CUE_EXPERIMENT=evalv3 cue export receipt.cue
receipt.3: structural cycle:
./receipt.cue:10:25
@slewiskelly would you be happy with this issue being marked as resolved by the new evaluator, then? A number of issues around disjunctions, cycle detection, and performance are resolved thanks to the new evaluator's design, and our focus is on polishing up the new evaluator so that we may enable it by default for all users as soon as possible. Any time spent trying to backport any fixes to the old evaluator would slow down that transition, as you can imagine.
Just as with previous cases like https://github.com/cue-lang/cue/issues/3149, I will still add a test case to the repository with your example, to make sure that it keeps working with the new evaluator.
What version of CUE are you using (
cue version
)?Does this issue reproduce with the latest stable release?
Yes.
What did you do?
What did you expect to see?
Would probably expect this to fail due to a cycle.
What did you see instead?
The value for
total
is18
, instead of6
.