Skip to content
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: comparison with bottom not consistent in the presence of defaults #3292

Open
myitcv opened this issue Jul 15, 2024 · 3 comments
Open

Comments

@myitcv
Copy link
Member

myitcv commented Jul 15, 2024

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.

@stouset
Copy link

stouset commented Jul 16, 2024

#3250

@myitcv
Copy link
Member Author

myitcv commented Jul 17, 2024

#3250

Thank you for flagging, I had missed that issue.

@mpvl
Copy link
Member

mpvl commented Aug 12, 2024

& does not "pick" a default (see spec). So foo.b & bool results in false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants