Skip to content

cue def --inline-imports mishandle labels #3854

Open
@fboismenu

Description

@fboismenu

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

$ cue version

cue version v0.12.0

go version go1.23.5
      -buildmode exe
       -compiler gc
       -trimpath true
     CGO_ENABLED 0
          GOARCH amd64
            GOOS linux
         GOAMD64 v1
cue.lang.version v0.12.0

Does this issue reproduce with the latest stable release?

Yes

What did you do?

Pretty hard to come with a minimal reproducer ...
But I have a construct looking like the following in a Cue file explicitly imported by the target of cue def --inline-imports target.cue

#TopLevel: {
	#AlertLabels: {
		P1: severity: "critical"
		P2: severity: "high"
		P3: severity: "moderate"
		P4: severity: "low"
		P5: severity: "info"
		...
	}

	#PriorityDelta: strconv.Atoi(strings.Split(_p_monitoring.alerting.priority, "P")[1]) - 1

	#AlertLabels: [Prio=string]: {
		// Compute final priority
		let _prioNum = strconv.Atoi(strings.Split(Prio, "P")[1])
		let _prio = list.Min([_prioNum + #PriorityDelta, 5])
		priority: "P\(_prio)"
...
}

And after cue def it becomes:

		#AlertLabels: {
			[Prio=string]: {
				let _prioNum = strconv.Atoi(strings.Split(string, "P")[1])

What did you expect to see?

The alias name has replaced by it's "type" constrain ...

What did you see instead?

		#AlertLabels: {
			[Prio=string]: {
				let _prioNum = strconv.Atoi(strings.Split(Prio, "P")[1])

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions