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

     1  // Issue #783
     2  
     3  -- in.cue --
     4  elipsis: {
     5  	test1: {
     6  		string
     7  		#foo: "bar"
     8  	}
     9  
    10  	#Def: {
    11  		...
    12  		#foo: string
    13  		_
    14  	}
    15  	check: test1 & #Def
    16  }
    17  
    18  bulk: {
    19  	test1: {
    20  		string
    21  		#foo: "bar"
    22  	}
    23  
    24  	#Def: {
    25  		[string]: int
    26  		#foo:     string
    27  		_
    28  	}
    29  	check: test1 & #Def
    30  }
    31  
    32  optional: {
    33  	test1: {
    34  		string
    35  		#foo: "bar"
    36  	}
    37  
    38  	#Def: {
    39  		bar?: int
    40  		#foo: string
    41  		_
    42  	}
    43  	check: test1 & #Def
    44  }
    45  
    46  issue783: {
    47  	test1: {
    48  		string
    49  		#foo: "bar"
    50  	}
    51  
    52  	test2: {
    53  		hello: "world"
    54  		#foo:  "bar"
    55  	}
    56  
    57  	#Def1: {
    58  		...
    59  		#foo: string
    60  	} | {
    61  		string
    62  		#foo: string
    63  	}
    64  	check1a: test1 & #Def1
    65  	check1b: test2 & #Def1
    66  
    67  	#Def2: {
    68  		...
    69  		#foo: string
    70  		_
    71  	}
    72  	check2a: test1 & #Def2
    73  	check2b: test2 & #Def2
    74  }
    75  -- out/eval --
    76  (struct){
    77    elipsis: (struct){
    78      test1: (string){
    79        string
    80        #foo: (string){ "bar" }
    81      }
    82      #Def: (_){
    83        _
    84        #foo: (string){ string }
    85      }
    86      check: (string){
    87        string
    88        #foo: (string){ "bar" }
    89      }
    90    }
    91    bulk: (struct){
    92      test1: (string){
    93        string
    94        #foo: (string){ "bar" }
    95      }
    96      #Def: (_){
    97        _
    98        #foo: (string){ string }
    99      }
   100      check: (string){
   101        string
   102        #foo: (string){ "bar" }
   103      }
   104    }
   105    optional: (struct){
   106      test1: (string){
   107        string
   108        #foo: (string){ "bar" }
   109      }
   110      #Def: (_){
   111        _
   112        #foo: (string){ string }
   113      }
   114      check: (string){
   115        string
   116        #foo: (string){ "bar" }
   117      }
   118    }
   119    issue783: (struct){
   120      test1: (string){
   121        string
   122        #foo: (string){ "bar" }
   123      }
   124      test2: (struct){
   125        hello: (string){ "world" }
   126        #foo: (string){ "bar" }
   127      }
   128      #Def1: ((string|struct)){ |((#struct){
   129          #foo: (string){ string }
   130        }, (string){
   131          string
   132          #foo: (string){ string }
   133        }) }
   134      check1a: (string){
   135        string
   136        #foo: (string){ "bar" }
   137      }
   138      check1b: (#struct){
   139        hello: (string){ "world" }
   140        #foo: (string){ "bar" }
   141      }
   142      #Def2: (_){
   143        _
   144        #foo: (string){ string }
   145      }
   146      check2a: (string){
   147        string
   148        #foo: (string){ "bar" }
   149      }
   150      check2b: (#struct){
   151        hello: (string){ "world" }
   152        #foo: (string){ "bar" }
   153      }
   154    }
   155  }
   156  -- out/compile --
   157  --- in.cue
   158  {
   159    elipsis: {
   160      test1: {
   161        string
   162        #foo: "bar"
   163      }
   164      #Def: {
   165        ...
   166        #foo: string
   167        _
   168      }
   169      check: (〈0;test1〉 & 〈0;#Def〉)
   170    }
   171    bulk: {
   172      test1: {
   173        string
   174        #foo: "bar"
   175      }
   176      #Def: {
   177        [string]: int
   178        #foo: string
   179        _
   180      }
   181      check: (〈0;test1〉 & 〈0;#Def〉)
   182    }
   183    optional: {
   184      test1: {
   185        string
   186        #foo: "bar"
   187      }
   188      #Def: {
   189        bar?: int
   190        #foo: string
   191        _
   192      }
   193      check: (〈0;test1〉 & 〈0;#Def〉)
   194    }
   195    issue783: {
   196      test1: {
   197        string
   198        #foo: "bar"
   199      }
   200      test2: {
   201        hello: "world"
   202        #foo: "bar"
   203      }
   204      #Def1: ({
   205        ...
   206        #foo: string
   207      }|{
   208        string
   209        #foo: string
   210      })
   211      check1a: (〈0;test1〉 & 〈0;#Def1〉)
   212      check1b: (〈0;test2〉 & 〈0;#Def1〉)
   213      #Def2: {
   214        ...
   215        #foo: string
   216        _
   217      }
   218      check2a: (〈0;test1〉 & 〈0;#Def2〉)
   219      check2b: (〈0;test2〉 & 〈0;#Def2〉)
   220    }
   221  }