Inconsistencies when unifying with templates #3674
Replies: 2 comments 3 replies
-
Simplifying to remove the template does show the expected result:
Generating |
Beta Was this translation helpful? Give feedback.
-
Thanks for raising, @mikelorant. I've transferred this to a discussion for now, until we clearly identify a bug/feature request that isn't covered elsewhere. The behaviour you are seeing is as expected given how templates are defined. The "issue" is that the template for
i.e. the template ends up also applying to the fields of To directly answer your question with a workaround, here is one approach (play): _foo: [string]: _source: "_foo"
_foo: {
a: i: 0
b: i: 1
}
_bar: {
c: i: 2
d: i: 3
}
_bar: {
[Key=_]: {
j: 1
}
}
for v in [_foo, _bar] for kk, vv in v {
baz: (kk): vv
} This is, however, nowhere near as elegant. There are a couple of options here:
|
Beta Was this translation helpful? Give feedback.
-
What version of CUE are you using (
cue version
)?Does this issue reproduce with the latest stable release?
Have reproduced this issue on both
v0.11.1
andv0.12.0-alpha.1
.What did you do?
I am attempting to unify two invisible structs where one of the structs is using a template.
The following example can be used to see the issue:
cue export bug.cue
bug.cue
What did you expect to see?
Only
c
andd
keys should have thej
key added to their values.Expected output is:
What did you see instead?
All keys under
baz
had thej
key added to their values.Actual output is:
Beta Was this translation helpful? Give feedback.
All reactions