cue-lang / cue

The home of the CUE language! Validate and define text-based and dynamic configuration
https://cuelang.org
Apache License 2.0
5.15k stars 297 forks source link

cue eval - missing items in for loop with let expressions #3591

Open timspeetjens opened 4 days ago

timspeetjens commented 4 days ago

What version of CUE are you using (cue version)?

$ cue version
cue version v0.11.0

go version go1.23.3
      -buildmode exe
       -compiler gc
       -trimpath true
     CGO_ENABLED 0
          GOARCH amd64
            GOOS linux
         GOAMD64 v1
cue.lang.version v0.11.0

Does this issue reproduce with the latest stable release?

Yes, 0.11.0, works as expected with 0.10.1

What did you do?

exec cue eval -c missing.cue
cmp stdout stdout.golden

-- missing.cue --
#Result: [_]: {[string]: string}

result: #Result

#Input: {
    p: "A" | "B"
}

_input: [Parm=_]: #Input & {
    p: Parm
}

_input: {
    A: {}
    B: {}
}

for _, v in _input {
    let Var1 = v.p
    let Var2 = Var1

    let Items = {
        "item": {
            key1: Var2
        }
    }

    result: "missing-items-\(v.p)": {
        for s, attr in Items {
            if attr.key1 != _|_ {(s): attr.key1}
        }
    }
}
-- stdout.golden --
result: {
    "missing-items-A": {
        item: "A"
    }
    "missing-items-B": {
        item: "B"
    }
}

What did you expect to see?

Passing test

What did you see instead?

result: {
    "missing-items-A": {}
    "missing-items-B": {}
}

It looks like this issue is related with #3590 - trying to simplify the reproducer even more, no more output was seen, but a conflicting values error was returned instead.

timspeetjens commented 4 days ago

Bisected to 396557964a4b90af732b19cea142b550d84f39e4