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

evalv3 does not obey CUE_DEBUG_SORT_ARCS=2 like the default evaluator #3460

Open
mvdan opened this issue Sep 23, 2024 · 0 comments
Open

evalv3 does not obey CUE_DEBUG_SORT_ARCS=2 like the default evaluator #3460

mvdan opened this issue Sep 23, 2024 · 0 comments
Labels
ordering Bugs where the evaluator behaves differently depending on the order of fields, files, etc.

Comments

@mvdan
Copy link
Member

mvdan commented Sep 23, 2024

$ cue version
cue version v0.11.0-alpha.1.0.20240920112956-687464eb1846+dirty

go version devel go1.24-165bf241f2 2024-09-19 00:40:50 +0000
      -buildmode exe
       -compiler gc
  DefaultGODEBUG asynctimerchan=1,gotypesalias=0,httpservecontentkeepheaders=1,multipathtcp=0,randseednop=0,tls3des=1,tlskyber=0,x509keypairleaf=0,x509negativeserial=1
     CGO_ENABLED 1
          GOARCH amd64
            GOOS linux
         GOAMD64 v3
             vcs git
    vcs.revision 687464eb1846e51628bb62e8e8804968bd300d69
        vcs.time 2024-09-20T11:29:56Z
    vcs.modified true
cue.lang.version v0.11.0

I would expect the following testscript to succeed:

env CUE_DEBUG_SORT_ARCS=2

env CUE_EXPERIMENT=
exec cue export
cmp stdout out.gold

env CUE_EXPERIMENT=evalv3
exec cue export
cmp stdout out.gold

-- file.cue --
package p

x: [_]: set: [string]: bool

x: [_]: {
	set: "aaa": true
	set: "zzz": true

	// Note that this bug depends on this field name sorting before the other.
	asList: [for p, _ in set {p}]
}

x: image1: set: ddd: true
-- out.gold --
{
    "x": {
        "image1": {
            "asList": [
                "aaa",
                "ddd",
                "zzz"
            ],
            "set": {
                "aaa": true,
                "ddd": true,
                "zzz": true
            }
        }
    }
}

However, it fails:

> env CUE_EXPERIMENT=evalv3
> exec cue export
[stdout]
{
    "x": {
        "image1": {
            "asList": [
                "ddd",
                "aaa",
                "zzz"
            ],
            "set": {
                "aaa": true,
                "ddd": true,
                "zzz": true
            }
        }
    }
}
> cmp stdout out.gold
diff stdout out.gold
--- stdout
+++ out.gold
@@ -2,8 +2,8 @@
     "x": {
         "image1": {
             "asList": [
-                "ddd",
                 "aaa",
+                "ddd",
                 "zzz"
             ],
             "set": {

FAIL: repro-evalv3.txtar:9: stdout and out.gold differ

evalv3 fails to sort the fields when looping in the list comprehension, so we get a non-sorted result.

@mvdan mvdan added the ordering Bugs where the evaluator behaves differently depending on the order of fields, files, etc. label Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ordering Bugs where the evaluator behaves differently depending on the order of fields, files, etc.
Projects
None yet
Development

No branches or pull requests

1 participant