Reference Fields From Embedded Values in CUE

· #cue · #cue/alias

CUE doesn’t define a direct method for referencing fields defined by an embedded value. The reason is that the identifier of the field being referenced isn’t inside defined in the current scope and embedding doesn’t alter the scope.

An embedded field can still be refereed to by either defining the referenced field inside the current scope or using a value alias of the current scope, I.e.

embedded: name: "World"

example: 1: {
	embedded
	name: _
	out: "Hello, \(name)!"
}

example: 2: s = {
	embedded
	out: "Hello, \(s.name)!"
}

An issue has been raised on GitHub for this behavior and it has been suggested to add . to mean current scope.