cue-lang/cue

evaluator: disjunction of structs creates new attributes out of thin air

nicuveo opened this issue · 0 comments

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

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

What did you do?

a: {
  r:1
  @foo(bar)
}
b:{
  r:2
  @foo(baz)
}
c: a | b

What did you expect to see?

a: {
	@foo(bar)
	r:1
}
b:{
	@foo(baz)
	r:2
}
c: {
	@foo(bar)
	r: 1
} | {
	@foo(baz)
	r: 2
}

What did you see instead?

a: {
	@foo(bar)
	r: 1
}
b: {
	@foo(baz)
	r: 2
}
c: {
	{
		@foo(bar)
		r: 1
	} |
	{
		@foo(baz)
		r: 2
	}
	@foo(baz)
}

This feels like a bug, especially since, unlike #2372, it keeps the attribute of the right-most element of the disjunction.