github.com/solo-io/cue@v0.4.7/cue/testdata/definitions/issue533.txtar (about)

     1  -- in.cue --
     2  package x
     3  
     4  #x: {
     5  	Name: string
     6  }
     7  
     8  _#x: {
     9  	Name: string
    10  }
    11  
    12  x1: #x & {
    13  	Name: "hello"
    14  	Age:  50
    15  }
    16  
    17  x2: _#x & {
    18  	Name: "hello"
    19  	Age:  50
    20  }
    21  -- out/eval --
    22  Errors:
    23  x1: field not allowed: Age:
    24      ./in.cue:3:5
    25      ./in.cue:11:5
    26      ./in.cue:13:2
    27  x2: field not allowed: Age:
    28      ./in.cue:7:6
    29      ./in.cue:16:5
    30      ./in.cue:18:2
    31  
    32  Result:
    33  (_|_){
    34    // [eval]
    35    #x: (#struct){
    36      Name: (string){ string }
    37    }
    38    _#x(:x): (#struct){
    39      Name: (string){ string }
    40    }
    41    x1: (_|_){
    42      // [eval]
    43      Name: (string){ "hello" }
    44      Age: (_|_){
    45        // [eval] x1: field not allowed: Age:
    46        //     ./in.cue:3:5
    47        //     ./in.cue:11:5
    48        //     ./in.cue:13:2
    49      }
    50    }
    51    x2: (_|_){
    52      // [eval]
    53      Name: (string){ "hello" }
    54      Age: (_|_){
    55        // [eval] x2: field not allowed: Age:
    56        //     ./in.cue:7:6
    57        //     ./in.cue:16:5
    58        //     ./in.cue:18:2
    59      }
    60    }
    61  }
    62  -- out/compile --
    63  --- in.cue
    64  {
    65    #x: {
    66      Name: string
    67    }
    68    _#x: {
    69      Name: string
    70    }
    71    x1: (〈0;#x〉 & {
    72      Name: "hello"
    73      Age: 50
    74    })
    75    x2: (〈0;_#x〉 & {
    76      Name: "hello"
    77      Age: 50
    78    })
    79  }