cue icon indicating copy to clipboard operation
cue copied to clipboard

evaluator: inconsistent export output for different formats based on what default is selected

Open gisle opened this issue 1 year ago • 3 comments
trafficstars

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

$ cue version
cue version v0.8.2

go version go1.22.2
      -buildmode exe
       -compiler gc
       -trimpath true
     CGO_ENABLED 0
          GOARCH arm64
            GOOS darwin

Does this issue reproduce with the latest stable release?

I belive v0.8.2 to be the latest stable release.

What did you do?

I tried to cue export based on this definition:

foo: *42 | _
foo: *43 | bool

What did you expect to see?

I expected it to actually complain about incompatible defaults, and if not that get consistent export output.

What did you see instead?

I see different result when I export as JSON than YAML or Cue.

$ cue export foo43.cue
{
    "foo": 43
}

$ cue export foo43.cue --out yaml
foo: 42

$ cue export foo43.cue --out cue
foo: 42

gisle avatar May 18 '24 09:05 gisle

Possibly related to #2916, as they share several elements (disjunctions, defaults, JSON-vs-YAML).

jpluscplusm avatar May 18 '24 09:05 jpluscplusm

This is a straight bug with the evaluator; neither is correct but the new evaluator is correct, i.e. the following test passes:

# old evaluator
env CUE_EXPERIMENT=''
exec cue export --out json x.cue
cmp stdout old_json.golden
exec cue export --out yaml x.cue
cmp stdout old_yaml.golden

# new evaluator
env CUE_EXPERIMENT='evalv3'
! exec cue export --out json x.cue
cmp stderr new_stderr.golden
! exec cue export --out yaml x.cue
cmp stderr new_stderr.golden

-- x.cue --
foo: *42 | _
foo: *43 | bool
-- old_json.golden --
{
    "foo": 43
}
-- old_yaml.golden --
foo: 42
-- new_stderr.golden --
foo: incomplete value 43 | bool

myitcv avatar May 23 '24 05:05 myitcv

@mvdan is kindly taking this one on to create a regression tests against the new evaluator.

myitcv avatar May 23 '24 14:05 myitcv