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

evalv2: matchN fails with list argument #3575

Open rogpeppe opened 2 weeks ago

rogpeppe commented 2 weeks ago

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

82995bbb

Does this issue reproduce with the latest stable release?

N/A (v0.10.0 doesn't implement matchN)

What did you do?

env CUE_EXPERIMENT=evalv3
exec cue vet x.cue

env CUE_EXPERIMENT=
exec cue vet x.cue

-- x.cue --
test1: {
    #x: matchN(1, [
        [{}],
    ])

    x: #x
    x: [{a: 1}]
}

test2: {
    #x: matchN(1, [
        {},
    ])
    x: #x
    x: {a: 1}
}

What did you expect to see?

Passing test. The struct should match with extra fields whether it's in a struct literal or not.

What did you see instead?

> env CUE_EXPERIMENT=evalv3
> exec cue vet x.cue
> env CUE_EXPERIMENT=
> exec cue vet x.cue
[stderr]
test1.x: invalid value [{a:1}] (does not satisfy matchN): 0 matched, expected 1:
    ./x.cue:2:6
    ./x.cue:2:13
    ./x.cue:6:5
    ./x.cue:7:5
[exit status 1]
FAIL: /tmp/x.txtar:5: unexpected command failure