cuelang.org/go@v0.10.1/cue/testdata/definitions/issue342.txtar (about)

     1  -- in.cue --
     2  X: {
     3  	#Simple: {
     4  		ref: string
     5  	}
     6  
     7  	#Complex: {
     8  		{
     9  			ref: string
    10  		} | {
    11  			local: string
    12  		}
    13  	}
    14  
    15  	var: "XXX"
    16  
    17  	// Validate(concrete) after Fill() on Complex.ref from a "static" key will succeed
    18  	"test_1": #Complex
    19  
    20  	// Validate(concrete) after Fill() on "#Simple.ref" from a "dynamic" key will succeed
    21  	"test_2_\(var)": #Simple
    22  
    23  	// Validate(concrete) after Fill() on Complex.ref from a "dynamic" key will fail
    24  	"test_3_\(var)": #Complex
    25  
    26  	test_3_XXX: ref: "FOO"
    27  }
    28  
    29  Z: X.test_3_XXX.ref
    30  -- out/eval/stats --
    31  Leaks:  0
    32  Freed:  24
    33  Reused: 17
    34  Allocs: 7
    35  Retain: 2
    36  
    37  Unifications: 18
    38  Conjuncts:    33
    39  Disjuncts:    24
    40  -- out/eval --
    41  (struct){
    42    X: (struct){
    43      #Simple: (#struct){
    44        ref: (string){ string }
    45      }
    46      #Complex: (#struct){ |((#struct){
    47          ref: (string){ string }
    48        }, (#struct){
    49          local: (string){ string }
    50        }) }
    51      var: (string){ "XXX" }
    52      test_1: (#struct){ |((#struct){
    53          ref: (string){ string }
    54        }, (#struct){
    55          local: (string){ string }
    56        }) }
    57      test_3_XXX: (#struct){
    58        ref: (string){ "FOO" }
    59      }
    60      test_2_XXX: (#struct){
    61        ref: (string){ string }
    62      }
    63    }
    64    Z: (string){ "FOO" }
    65  }
    66  -- out/compile --
    67  --- in.cue
    68  {
    69    X: {
    70      #Simple: {
    71        ref: string
    72      }
    73      #Complex: {
    74        ({
    75          ref: string
    76        }|{
    77          local: string
    78        })
    79      }
    80      var: "XXX"
    81      test_1: 〈0;#Complex〉
    82      "test_2_\(〈0;var〉)": 〈0;#Simple〉
    83      "test_3_\(〈0;var〉)": 〈0;#Complex〉
    84      test_3_XXX: {
    85        ref: "FOO"
    86      }
    87    }
    88    Z: 〈0;X〉.test_3_XXX.ref
    89  }