cue icon indicating copy to clipboard operation
cue copied to clipboard

evaluator: field dropped when data transformed into list

Open nxcc opened this issue 1 year ago • 6 comments

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

$ cue version
cue version v0.6.0

go version go1.20.6
      -buildmode exe
       -compiler gc
       -trimpath true
     CGO_ENABLED 0
          GOARCH amd64
            GOOS linux
         GOAMD64 v1

Does this issue reproduce with the latest stable release?

yes

What did you do?

with test.cue:

package kube

configMap: cm: data: myvalue: "42"

configMap: [ID=_]: this={
	(#metadataName & {id: ID, data: this.data, disable: this._disableNameSuffixHash}).out
}

configMap: [ID=_]: {
	_disableNameSuffixHash: *false | bool
	metadata: labels: {f: "1"}
}

objectSets: [ configMap]
objects: [ for v in objectSets for x in v {x}]

#metadataName: {
	id:      string
	disable: bool
	if !disable {
		out: metadata: name: id + "-my-suffix"
	}
	if disable {
		out: metadata: name: id
	}
}

execute cue export -e 'objects[0].metadata.name' test.cue

What did you expect to see?

"cm-my-suffix"

What did you see instead?

undefined field: name:
    --expression:1:21

nxcc avatar Aug 11 '23 15:08 nxcc