Skip to content

eval: disjunction errors when repeating a sub-schema #3855

Open
@mvdan

Description

@mvdan

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

$ cue version
$ cue version
cue version v0.13.0-alpha.2.0.20250327101324-32d040003e8a

go version devel go1.25-1763ee199d 2025-03-26 17:58:32 -0700
      -buildmode exe
       -compiler gc
  DefaultGODEBUG decoratemappings=0,gotestjsonbuildtext=1,multipathtcp=0,randseednop=0,rsa1024min=0,tlsmlkem=0,x509rsacrt=0,x509usepolicies=0
     CGO_ENABLED 1
          GOARCH amd64
            GOOS linux
         GOAMD64 v3
             vcs git
    vcs.revision 32d040003e8a43b96d667d1ec2a2a02957853577
        vcs.time 2025-03-27T10:13:24Z
    vcs.modified false
cue.lang.version v0.13.0

Does this issue reproduce with the latest stable release?

Yes; tested on v0.12.0 with evalv2 too.

What did you do?

# evalv2
env CUE_EXPERIMENT=evalv3=0
exec cue export

# evalv3
env CUE_EXPERIMENT=evalv3=1
exec cue export

-- input.cue --
package p

#schema: {
	a: "a1" | "a2"

	if a == "a1" { b: "b" }
	if a == "a2" { c: "c" }

	x: "x1" | "x2"
}

out: #schema & {
	a: "a2"
	// Remove `#schema.x &` and the config works.
	x: #schema.x & "x1"
}

What did you expect to see?

The testscript should pass, at least with evalv3; as far as I can tell, the configuration is valid. The repeating of the schema for the field out.x should not cause any issues.

What did you see instead?

# evalv2 (0.011s)
> env CUE_EXPERIMENT=evalv3=0
> exec cue export
[stderr]
out.x: 3 errors in empty disjunction:
out.x: conflicting values "x2" and "x1":
    ./input.cue:9:12
    ./input.cue:12:6
    ./input.cue:15:17
#schema: unresolved disjunction "a1" | "a2" (type string):
    ./input.cue:6:5
#schema: unresolved disjunction "a1" | "a2" (type string):
    ./input.cue:7:5
[exit status 1]
FAIL: repro-evalv3.txtar:3: unexpected command failure
# evalv3 (0.029s)
> env CUE_EXPERIMENT=evalv3=1
> exec cue export
[stderr]
out.x: 3 errors in empty disjunction:
out.x: conflicting values "x2" and "x1":
    ./input.cue:9:12
    ./input.cue:15:17
#schema: unresolved disjunction "a1" | "a2" (type string):
    ./input.cue:6:5
#schema: unresolved disjunction "a1" | "a2" (type string):
    ./input.cue:7:5
[exit status 1]
FAIL: repro-evalv3.txtar:7: unexpected command failure

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions