cue-lang/cue

evaluator: aliasing to a constraint results in invalid output.

nicuveo opened this issue · 1 comments

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

The playground (v0.5.1-0.20230413144408-f681271a38ec and v0.6.0-alpha.1.0.20230428121230-80d6ea032057).

What did you do?

r = [string]: {b: r}
a: {r: 0}

What did you expect to see?

Regardless of whether we are to understand r as a reference to a, the actual field being matched, when evaluating b, or as a reference to the body of the constraint, it should result in a structural cycle, since it would be equivalent to either a: {b: a} or to cond_1: r = {b: r}.

What did you see instead?

This invalid output, which makes a reference to a non-existent field or alias.

a: {
	r: 0
	b: r_1
}

let r_1 = r

Sidenotes.

  • this output also shows an example of alias renaming, a behaviour that's not documented in the specification
  • i don't think i have been able to come up with an example of an alias to a constraint making sense / being used in a way that didn't result in a structural cycle / evaluation problem; is there any plan to remove this feature / deprecate it?
myitcv commented

Marking as triage to bisect. Tentatively scheduling for v0.7.0 so we don't double up on work in v0.6.0 (changes in v0.7.0 make fixing this easier).