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.02k stars 286 forks source link

evaluator: incompatible list element constraints not detected #3302

Open myitcv opened 1 month ago

myitcv commented 1 month ago

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?

! exec cue vet x.cue
stderr 'incompatible list element types string and int'

-- x.cue --
x: [...string] & [...int]

What did you expect to see?

Passing test.

What did you see instead?

> ! exec cue vet x.cue
FAIL: /tmp/testscript22070679/repro.txtar/script.txtar:1: unexpected command success

i.e. there is currently no error as a result of this conjunction when there should be. Indeed it is impossible to produce anything other than an zero-element list with this construction.

Note that when we have fixed this issue we should also ensure that https://github.com/cue-lang/cue/issues/1654 is fixed.

mpvl commented 1 month ago

Theoretically this is not an error. It basically is an elaborate way of specifying that x must be the empty list.

I agree that vet could be stricter and give more useful user feedback, but as of now vet does not do that yet.