-
Notifications
You must be signed in to change notification settings - Fork 292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
evaluator: unexpected behavior of list.Sum
#3310
Comments
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}])
} |
list.Sum
list.Sum
Thanks very much for the report, @slewiskelly. The new evaluator does see this as a cycle (the following test passes, as of f5b905c):
|
Sorry, I completely forgot to try with $ 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 #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. |
The sum in the changed test was summing itself, which is a structural cycle. The old behavior was to give a garbage result. We now correctly report the structural cycle. Issue #3310 Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com> Change-Id: Ia37a3a0adf373e9455dc921916a1352ebd580b44 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1202444 Reviewed-by: Matthew Sackman <matthew@cue.works> TryBot-Result: CUEcueckoo <cueckoo@cuelang.org> Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
The sum in the changed test was summing itself, which is a structural cycle. The old behavior was to give a garbage result. We now correctly report the structural cycle. Issue cue-lang#3310 Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com> Change-Id: Ia37a3a0adf373e9455dc921916a1352ebd580b44 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1202444 Reviewed-by: Matthew Sackman <matthew@cue.works> TryBot-Result: CUEcueckoo <cueckoo@cuelang.org> Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
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
.The text was updated successfully, but these errors were encountered: