cue
cue copied to clipboard
evaluator: cycle error incorrectly reported for non-concrete field
What version of CUE are you using (cue version)?
$ cue version
cue version v0.0.0-20220825081001-d3c14a684375
-compiler gc
CGO_ENABLED 1
GOARCH arm64
GOOS linux
vcs git
vcs.revision d3c14a68437588b9dbdec9cb3919f7aafec58111
vcs.time 2022-08-25T08:10:01Z
vcs.modified false
Does this issue reproduce with the latest release?
Yes
What did you do?
# This should fail with an error about a and b being
# incomplete
! exec cue export x.cue
stderr 'a: incomplete value'
stderr 'b: incomplete value'
-- x.cue --
x: 200
x: y + 100
y: x - 100
a: b + 100
b: a - 100
What did you expect to see?
Passing test.
What did you see instead?
# This should fail with an error about a and b being
# incomplete (0.014s)
> ! exec cue export x.cue
[stderr]
cycle error:
./x.cue:5:4
[exit status 1]
> stderr 'a: incomplete value'
FAIL: /tmp/testscript4050841429/repro.txtar/script.txt:4: no match for `a: incomplete value` found in stderr
Related to #1884.
cc @mpvl
Cycle errors (not to be confused with structural cycles) are a kind of incomplete error. So this is correct. The spec mentions that cycles can be broken.
So this is mostly a documentation / presentation thing.
Also porting the example from #1778 which I totally forgot I raised with @rogpeppe before:
What did you do?
# Below, a.cue and b.cue are identical, but for the order
# of _t and r.
# With _t before r
! exec cue export a.cue
stderr 'non-concrete value string'
# With r before _t
! exec cue export b.cue
stderr 'non-concrete value string'
-- a.cue --
_t: {
#p: string
"""
hello \(#p)
"""
}
r: """
\(_t)
"""
-- b.cue --
r: """
\(_t)
"""
_t: {
#p: string
"""
hello \(#p)
"""
}
What did you expect?
Passing test
What did you see instead?
# Below, a.cue and b.cue are identical, but for the order
# of _t and r.
# With _t before r (0.013s)
# With r before _t (0.011s)
> ! exec cue export b.cue
[stderr]
invalid interpolation: cycle error:
./b.cue:1:4
[exit status 1]
> stderr 'non-concrete value string'
FAIL: /tmp/testscript937876582/repro.txtar/script.txtar:10: no match for `non-concrete value string` found in stderr
The error message here is also not ideal because it doesn't say exactly what was non-concrete.