cue icon indicating copy to clipboard operation
cue copied to clipboard

evaluator: error with disjunction containing default value is needlessly verbose

Open rogpeppe opened this issue 3 years ago • 0 comments

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

$ cue version
cue version v0.0.0-20220901114913-d2250b9bc187

       -compiler gc
     CGO_ENABLED 1
          GOARCH amd64
            GOOS linux
         GOAMD64 v1
             vcs git
    vcs.revision d2250b9bc1870a2488ee3f33b4e8e4fd0561a5f3
        vcs.time 2022-09-01T11:49:13Z
    vcs.modified false

What did you do?

! exec cue vet x.cue
cmp stderr stderr.golden

-- x.cue --
// This would usually be in a schema
x: >50

// This might be in a template or somewhere that defines defaults.
x: *1 | _

// This represents the user data
x: 4

-- stderr.golden --
x: 2 errors in empty disjunction:
x: conflicting values 1 and 4:
    ./x.cue:5:5
    ./x.cue:8:4
x: invalid value 4 (out of bound >50):
    ./x.cue:2:4
    ./x.cue:8:4

The output in that test is more verbose than it could be. Although technically correct, the fact that the default value conflicts with another value and is thus eliminated from the disjunction is not useful information and could probably be omitted.

It would be perhaps less confusing to see a single error like this instead:

x: invalid value 4 (out of bound >50):
    ./x.cue:2:4
    ./x.cue:8:4

rogpeppe avatar Sep 01 '22 17:09 rogpeppe