blob: 6b59407541e9e207416a827ecc7ae83232b103de [file] [log] [blame]
cue eval -i -c cycle.cue
cmp stdout expect-stdout-cue
-- frontmatter.toml --
title = "Reference Cycles"
description = ""
-- text.md --
CUE can handle many types of cycles just fine.
Because all values are final, a field with a concrete value of, say `200`,
can only be valid if it is that value.
So if it is unified with another expression, we can delay the evaluation of
this until later.
By postponing that evaluation, we can often break cycles.
This is very useful for template writers that may not know what fields
a user will want to fill out.
-- cycle.cue --
// CUE knows how to resolve the following:
x: 200
x: y + 100
y: x - 100
// If a cycle is not broken, CUE will just report it.
a: b + 100
b: a - 100
-- expect-stdout-cue --
x: 200
y: 100
a: _|_ // cycle detected
b: _|_ // cycle detected