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

     1  -- in.cue --
     2  comprehensions: {
     3  	a: {}
     4  	b: {
     5  		if a.b {
     6  		}
     7  	}
     8  	c: {
     9  		for x in a.b {x}
    10  	}
    11  }
    12  
    13  openStruct: {
    14  	a: {}
    15  	b: a.c
    16  }
    17  
    18  selectFromTop: {
    19  	top: _
    20  	a:   top.foo
    21  }
    22  
    23  indexOnTop: {
    24  	top: _
    25  	a:   top[2]
    26  }
    27  
    28  incompleteIndex: {
    29  	top: _
    30  	a:   [1][top]
    31  }
    32  -- out/eval --
    33  Errors:
    34  incompleteIndex.a: invalid index top (invalid type _):
    35      ./in.cue:29:7
    36      ./in.cue:29:11
    37  
    38  Result:
    39  (_|_){
    40    // [eval]
    41    comprehensions: (struct){
    42      a: (struct){
    43      }
    44      b: (_|_){
    45        // [incomplete] comprehensions.b: undefined field: b:
    46        //     ./in.cue:4:8
    47      }
    48      c: (_|_){
    49        // [incomplete] comprehensions.c: undefined field: b:
    50        //     ./in.cue:8:14
    51      }
    52    }
    53    openStruct: (struct){
    54      a: (struct){
    55      }
    56      b: (_|_){
    57        // [incomplete] openStruct.b: undefined field: c:
    58        //     ./in.cue:14:7
    59      }
    60    }
    61    selectFromTop: (struct){
    62      top: (_){ _ }
    63      a: (_|_){
    64        // [incomplete] selectFromTop.a: top.foo undefined as top is incomplete (type _):
    65        //     ./in.cue:19:7
    66      }
    67    }
    68    indexOnTop: (struct){
    69      top: (_){ _ }
    70      a: (_|_){
    71        // [incomplete] indexOnTop.a: top[2] undefined as top is incomplete (type _):
    72        //     ./in.cue:24:7
    73      }
    74    }
    75    incompleteIndex: (_|_){
    76      // [eval]
    77      top: (_){ _ }
    78      a: (_|_){
    79        // [eval] incompleteIndex.a: invalid index top (invalid type _):
    80        //     ./in.cue:29:7
    81        //     ./in.cue:29:11
    82      }
    83    }
    84  }
    85  -- out/compile --
    86  --- in.cue
    87  {
    88    comprehensions: {
    89      a: {}
    90      b: {
    91        if 〈1;a〉.b {}
    92      }
    93      c: {
    94        for _, x in 〈1;a〉.b {
    95          〈1;x〉
    96        }
    97      }
    98    }
    99    openStruct: {
   100      a: {}
   101      b: 〈0;a〉.c
   102    }
   103    selectFromTop: {
   104      top: _
   105      a: 〈0;top〉.foo
   106    }
   107    indexOnTop: {
   108      top: _
   109      a: 〈0;top〉[2]
   110    }
   111    incompleteIndex: {
   112      top: _
   113      a: [
   114        1,
   115      ][〈0;top〉]
   116    }
   117  }