blob: a79edaca2acc1f99af8ebd8f6f7afa2b9c64f8f6 [file] [log] [blame]
cue eval -i structs.cue
cmp stdout expect-stdout-cue
-- frontmatter.toml --
title = "Closed structs"
description = ""
-- text.md --
Struct is the most important composite type in CUE.
A struct may be open or closed.
A closed struct may only be merged with structs that have fields that
it defines to be allowed.
In other words, closing a struct is equivalent to requiring that all
other values be undefined.
A closed struct can be created using the `close` builtin,
but are more commonly defined using a _definition_, defined next.
-- structs.cue --
a: close({
field: int
})
b: a & {
feild: 3
}
-- expect-stdout-cue --
a: {
field: int
}
b: _|_ // field "feild" not allowed in closed struct