github.com/joomcode/cue@v0.4.4-0.20221111115225-539fe3512047/cue/testdata/eval/bulk.txtar (about)

     1  -- in.cue --
     2  a: {
     3  	foo: a: 1
     4  	[X = =~"foo"]: {
     5  		b:    1
     6  		name: X
     7  	}
     8  }
     9  d: a & {
    10  	"foobar": {
    11  		c: 2
    12  	}
    13  }
    14  
    15  t1: {
    16  	#a: {
    17  		[>"e" & <"z"]: int
    18  	}
    19  	b: #a & {f: 4}
    20  	c: #a & {z: 4}
    21  }
    22  
    23  t2: {
    24  	#a: {
    25  		["x" | "y"]: int
    26  	}
    27  	b: #a & {x: 4}
    28  	c: #a & {z: 4}
    29  }
    30  -- out/eval --
    31  Errors:
    32  t1.c: field not allowed: z:
    33      ./in.cue:15:6
    34      ./in.cue:19:5
    35      ./in.cue:19:11
    36  t2.c: field not allowed: z:
    37      ./in.cue:23:6
    38      ./in.cue:27:5
    39      ./in.cue:27:11
    40  
    41  Result:
    42  (_|_){
    43    // [eval]
    44    a: (struct){
    45      foo: (struct){
    46        a: (int){ 1 }
    47        b: (int){ 1 }
    48        name: (string){ "foo" }
    49      }
    50    }
    51    d: (struct){
    52      foo: (struct){
    53        a: (int){ 1 }
    54        b: (int){ 1 }
    55        name: (string){ "foo" }
    56      }
    57      foobar: (struct){
    58        c: (int){ 2 }
    59        b: (int){ 1 }
    60        name: (string){ "foobar" }
    61      }
    62    }
    63    t1: (_|_){
    64      // [eval]
    65      #a: (#struct){
    66      }
    67      b: (#struct){
    68        f: (int){ 4 }
    69      }
    70      c: (_|_){
    71        // [eval]
    72        z: (_|_){
    73          // [eval] t1.c: field not allowed: z:
    74          //     ./in.cue:15:6
    75          //     ./in.cue:19:5
    76          //     ./in.cue:19:11
    77        }
    78      }
    79    }
    80    t2: (_|_){
    81      // [eval]
    82      #a: (#struct){
    83      }
    84      b: (#struct){
    85        x: (int){ 4 }
    86      }
    87      c: (_|_){
    88        // [eval]
    89        z: (_|_){
    90          // [eval] t2.c: field not allowed: z:
    91          //     ./in.cue:23:6
    92          //     ./in.cue:27:5
    93          //     ./in.cue:27:11
    94        }
    95      }
    96    }
    97  }
    98  -- out/compile --
    99  --- in.cue
   100  {
   101    a: {
   102      foo: {
   103        a: 1
   104      }
   105      [=~"foo"]: {
   106        b: 1
   107        name: 〈1;-〉
   108      }
   109    }
   110    d: (〈0;a〉 & {
   111      foobar: {
   112        c: 2
   113      }
   114    })
   115    t1: {
   116      #a: {
   117        [(>"e" & <"z")]: int
   118      }
   119      b: (〈0;#a〉 & {
   120        f: 4
   121      })
   122      c: (〈0;#a〉 & {
   123        z: 4
   124      })
   125    }
   126    t2: {
   127      #a: {
   128        [("x"|"y")]: int
   129      }
   130      b: (〈0;#a〉 & {
   131        x: 4
   132      })
   133      c: (〈0;#a〉 & {
   134        z: 4
   135      })
   136    }
   137  }