cue: relax rules for closed structs

Closedness constraints of literal structs now don't take
effect until after a field expression is evaluated.

This is only part of the implementatation. Several
aspects are implemented in follow-up CLs.

Change-Id: I588223cd555f8cde537ade7caf1901e6e425291a
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/3640
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/doc/ref/spec.md b/doc/ref/spec.md
index cc6ad2c..f07149d 100644
--- a/doc/ref/spec.md
+++ b/doc/ref/spec.md
@@ -1330,8 +1330,18 @@
 to be concrete when emitting data.
 It is illegal to have a regular field and a definition with the same name
 within the same struct.
-Literal structs that are part of a definition's value are implicitly closed.
+Literal structs that are part of a definition's value are implicitly closed,
+but may unify unrestricted with other structs within the field's declaration.
 This excludes literals structs in embeddings and aliases.
+<!--
+This may be a more intuitive definition:
+    Literal structs that are part of a definition's value are implicitly closed.
+    Implicitly closed literal structs that are unified within
+    a single field declaration are considered to be a single literal struct.
+However, this would make unification non-commutative, unless one imposes an
+ordering where literal structs are unified before unifying them with others.
+Imposing such an ordering is complex and error prone.
+-->
 An ellipsis `...` in such literal structs keeps them open,
 as it defines `_` for all labels.
 <!--
@@ -1359,22 +1369,17 @@
 -->
 
 ```
-// MyStruct is closed and as there is no expression label or `...`, we know
-// this is the full definition.
 MyStruct :: {
-    field:    string
-    enabled?: bool
+    sub field:    string
 }
 
-// Without the `...`, this field would not unify with its previous declaration.
 MyStruct :: {
-    enabled: bool | *false
-    ...
+    sub enabled?: bool
 }
 
 myValue: MyStruct & {
-    feild:   2     // error, feild not defined in MyStruct
-    enabled: true  // okay
+    sub feild:   2     // error, feild not defined in MyStruct
+    sub enabled: true  // okay
 }
 
 D :: {
@@ -1441,6 +1446,7 @@
 // attr:  int    @xml(,attr) @xml(a1,attr) @go(Attr)
 ```
 
+
 #### Aliases
 
 In addition to fields, a struct literal may also define aliases.