cue
cue copied to clipboard
evaluator: comparison with bottom not consistent in the presence of defaults
What version of CUE are you using (cue version)?
$ cue version
cue version v0.0.0-20240712164527-719893f23850
go version go1.22.3
-buildmode exe
-compiler gc
DefaultGODEBUG httplaxcontentlength=1,httpmuxgo121=1,tls10server=1,tlsrsakex=1,tlsunsafeekm=1
CGO_ENABLED 1
GOARCH arm64
GOOS linux
vcs git
vcs.revision 719893f23850172d224720e6d1257586179ac895
vcs.time 2024-07-12T16:45:27Z
vcs.modified false
cue.lang.version v0.10.0
Does this issue reproduce with the latest release?
Yes
What did you do?
# evalv3
env CUE_EXPERIMENT=evalv3
exec cue export x.cue
cmp stdout stdout.golden
# old evaluator
env CUE_EXPERIMENT=
exec cue export x.cue
cmp stdout stdout.golden
-- x.cue --
foo: {
a: false | *{}
b: false | *{}
}
foo: a: {}
a: [
if (foo.a & bool) != _|_ {"false"},
if (foo.a & {}) != _|_ {"map"},
][0]
b: [
if (foo.b & bool) != _|_ {"false"},
if (foo.b & {}) != _|_ {"map"},
][0]
-- stdout.golden --
{
"foo": {
"a": {},
"b": {}
},
"a": "map",
"b": "map"
}
What did you expect to see?
Passing test.
What did you see instead?
# evalv3 (0.013s)
> env CUE_EXPERIMENT=evalv3
> exec cue export x.cue
[stdout]
{
"foo": {
"a": {},
"b": {}
},
"a": "map",
"b": "false"
}
> cmp stdout stdout.golden
diff stdout stdout.golden
--- stdout
+++ stdout.golden
@@ -4,5 +4,5 @@
"b": {}
},
"a": "map",
- "b": "false"
+ "b": "map"
}
FAIL: /tmp/testscript3437600263/repro.txtar/script.txtar:4: stdout and stdout.golden differ
For completeness, the same error is seen with the old evaluator, i.e. neither consistently handles comparison with bottom in the presence of defaults.
This is related to #943 in that comparison with bottom is not well defined.
https://github.com/cue-lang/cue/issues/3250
#3250
Thank you for flagging, I had missed that issue.
& does not "pick" a default (see spec). So foo.b & bool results in false.