cue icon indicating copy to clipboard operation
cue copied to clipboard

evaluator: aliases not tolerated on top level of list items

Open seh opened this issue 3 years ago • 4 comments

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

v0.5.0-beta.2.0.20221216062120-45aa5c093e71

Does this issue reproduce with the latest release?

Version 0.4.3 behaves the same way.

What did you do?

Attempt to use an alias on a struct value, so as to refer to sibling fields within the struct using the alias. In this example, we wish for our "together" field to refer to the sibling "_suffix" field that's introduced by way of unification.

let prelude = {
    _suffix: "art"
}

outside: V=(prelude & {
    together: "st\(V._suffix)"
})

inside: [
    V=(prelude & {
        together: "st\(V._suffix)"
    })
]

This example is available in the CUE Playground.

Note that the top-level "outside" field's value works as expected: it winds up with the following value:

{
  "together": "start"
}

However, the "inside" field's value is a list, and when we attempt to use the same expression to define the first item in the list, CUE rejects our attempted use of the the alias, reporting the following complaint:

inside: alias values not allowed in this position: -:10:5

What did you expect to see?

CUE should export the following struct:

outside: {
	together: "start"
}
inside: [{
	together: "start"
}]

What did you see instead?

CUE refuses to evaluate the source code, complaining about the alias inside the list literal:

inside: alias values not allowed in this position: -:10:5

seh avatar Dec 16 '22 17:12 seh

Already in spec, but not yet implemented.

mpvl avatar Jun 14 '23 12:06 mpvl

Marking as v0.8.0 and "Needs fix" - not because it's a bug, rather more a TODO per @mpvl. Because we've indicated in the spec that we will support this, but it's not yet implemented. The one "positive" here is that the spec makes clear it is not yet implemented :)

myitcv avatar Jun 14 '23 12:06 myitcv

See #4014 for renewed hope on this front.

seh avatar Aug 19 '25 23:08 seh

Indeed this spec deviation bug will disappear with the aliasv2 language change: https://github.com/cue-lang/cue/discussions/4014

mvdan avatar Dec 06 '25 14:12 mvdan