cue: "incomplete value" regression in evalv3 which appears to be order dependent

# With the old evaluator.
env CUE_EXPERIMENT=evalv3=0
exec cue vet -c

# With the new evaluator.
env CUE_EXPERIMENT=evalv3=1
exec cue vet -c

-- input.cue --
package p

routes: default: {}
routes: [string]: spec: [{
	refs: [{"default"}]
}]
#Fields: {
	input: _
	output: [for x in input { x }]
	...
}
#Kubernetes: {
	#Fields & {
		Routes: route: [_]: spec!: HTTPROUTESPEC.#x
	}
	#Fields // Commenting out this line also fixes evalv3.
	Routes: _
	input: res1: Routes
}
let HTTPROUTESPEC = {
	#x: [...{
		refs: [...{string}]
	}] | *[{
		other: []
	}]
}

// Order dependent! Breaks if the lines below are moved to the top of the file.
entrypoint: used.output
used: #Kubernetes & {
	Routes: route: routes
}

As of 46fc54aa9caf95393dcd3fe0ac066c8112da986d:

# With the old evaluator. (0.010s)
> env CUE_EXPERIMENT=evalv3=0
> exec cue vet -c
# With the new evaluator. (0.030s)
> env CUE_EXPERIMENT=evalv3=1
> exec cue vet -c
[stderr]
used.output.0.route.default.spec: incomplete value [{refs:["default"]}] | [{refs:["default"],other:[]}]
[exit status 1]

See the comments; removing one repetitive definition embedding, or moving the last two fields to the top of the file, both make the error go away. So it seems like there’s some rather nasty bug in evalv3 that causes order-dependent or inconsistent evaluation.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (11 by maintainers)

Commits related to this issue

Most upvoted comments

@mvdan was going to follow up with you, but these hugely detailed replies give us plenty to work through.

He did, thanks… I’m concerned they’re counter-productive so please let me know if that’s the case are and I’ll edit them down or delete them entirely.

For posterity, here is a runtime visualization of just before the disjunction is computed of

// use regular field
input: k1: foo: a: 1
input: k1: foo: #x
out: {
	for x in input { x }
	for x in input { x }
}
#x: { a: int } | *{ b: 2 }

and

// use pattern constraint
input: k1: [string]: a: 1
input: k1: foo: #x
out: {
	for x in input { x }
	for x in input { x }
}
#x: { a: int } | *{ b: 2 }

The graph with the pattern constraint case is clearly broken (if you know what to look for). Most notably, the ARC link is missing. This causes a whole path (red) to be ignored in the disjunction. The ARC was missing because it erroneously got deduped. Once that was fixed it behaved exactly as the regular field case, as one would expect.

Image

Image

Reduced from a failure in Holos as reported by @jeffmccune. Note that https://github.com/cue-lang/cue/issues/3637 was a spin-off from the example above, but a different bug entirely.