cuelang.org/go@v0.10.1/cue/testdata/resolve/016_index.txtar (about)

     1  # DO NOT EDIT; generated by go run testdata/gen.go
     2  #
     3  #name: index
     4  #evalPartial
     5  -- in.cue --
     6  a: [2][0]
     7  b: {foo:       "bar"}["foo"]
     8  c: (*l | {"3": 3})["3"]
     9  d: (*[] | [1])[0]
    10  l: []
    11  e1: [2][""]
    12  e2: 2[2]
    13  e3: [][true]
    14  e4: [1, 2, 3][3]
    15  e5: [1, 2, 3][-1]
    16  e6: (*[] | {})[1]
    17  e7: [1, 2, 3][3]
    18  e8: [1, 2, 3][-1]
    19  e9: (*[] | {})[1]
    20  
    21  def: {
    22  	a:  1
    23  	#b: 3
    24  }
    25  e7: def["b"]
    26  -- out/def --
    27  a: 2
    28  b: "bar"
    29  c: _|_ // invalid list index "3" (type string)
    30  l: []
    31  d:  _|_ // index 0 out of bounds
    32  e1: _|_ // invalid list index "" (type string)
    33  e2: _|_ // invalid operation: 2[2] (type int does not support indexing)
    34  e3: _|_ // invalid list index true (type bool)
    35  e4: _|_ // index 3 out of bounds
    36  e5: _|_ // invalid list index -1 (index must be non-negative)
    37  e6: _|_ // index 1 out of bounds
    38  def: {
    39  	a:  1
    40  	#b: 3
    41  }
    42  e7: def["b"]
    43  -- out/legacy-debug --
    44  <0>{a: 2, b: "bar", c: _|_("3":invalid list index "3" (type string)), l: [], d: _|_([]:index 0 out of bounds), e1: _|_("":invalid list index "" (type string)), e2: _|_(2:invalid operation: 2[2] (type int does not support indexing)), e3: _|_(true:invalid list index true (type bool)), e4: _|_([1,2,3]:index 3 out of bounds), e5: _|_(-1:invalid list index -1 (index must be non-negative)), e6: _|_([]:index 1 out of bounds), def: <1>{a: 1, #b: 3}, e7: <2>.def["b"]}
    45  -- out/compile --
    46  --- in.cue
    47  {
    48    a: [
    49      2,
    50    ][0]
    51    b: {
    52      foo: "bar"
    53    }["foo"]
    54    c: (*〈0;l〉|{
    55      "3": 3
    56    })["3"]
    57    d: (*[]|[
    58      1,
    59    ])[0]
    60    l: []
    61    e1: [
    62      2,
    63    ][""]
    64    e2: 2[2]
    65    e3: [][true]
    66    e4: [
    67      1,
    68      2,
    69      3,
    70    ][3]
    71    e5: [
    72      1,
    73      2,
    74      3,
    75    ][-1]
    76    e6: (*[]|{})[1]
    77    e7: [
    78      1,
    79      2,
    80      3,
    81    ][3]
    82    e8: [
    83      1,
    84      2,
    85      3,
    86    ][-1]
    87    e9: (*[]|{})[1]
    88    def: {
    89      a: 1
    90      #b: 3
    91    }
    92    e7: 〈0;def〉["b"]
    93  }
    94  -- out/eval/stats --
    95  Leaks:  10
    96  Freed:  32
    97  Reused: 26
    98  Allocs: 16
    99  Retain: 12
   100  
   101  Unifications: 34
   102  Conjuncts:    44
   103  Disjuncts:    42
   104  -- out/evalalpha --
   105  Errors:
   106  c: undefined field: "3":
   107      ./in.cue:3:20
   108  d: index out of range [0] with length 0:
   109      ./in.cue:4:16
   110  e1: undefined field: "":
   111      ./in.cue:6:9
   112  e2: invalid operand 2 (found int, want list or struct):
   113      ./in.cue:7:5
   114  e3: invalid index true (invalid type bool):
   115      ./in.cue:8:5
   116      ./in.cue:8:8
   117  e4: index out of range [3] with length 3:
   118      ./in.cue:9:15
   119  e5: invalid index -1 (index must be non-negative):
   120      ./in.cue:10:5
   121      ./in.cue:10:15
   122  e6: index out of range [1] with length 0:
   123      ./in.cue:11:16
   124  e7: index out of range [3] with length 3:
   125      ./in.cue:12:15
   126  e8: invalid index -1 (index must be non-negative):
   127      ./in.cue:13:5
   128      ./in.cue:13:15
   129  e9: index out of range [1] with length 0:
   130      ./in.cue:14:16
   131  
   132  Result:
   133  (_|_){
   134    // [eval]
   135    a: (int){ 2 }
   136    b: (string){ "bar" }
   137    c: (_|_){
   138      // [eval] c: undefined field: "3":
   139      //     ./in.cue:3:20
   140    }
   141    d: (_|_){
   142      // [eval] d: index out of range [0] with length 0:
   143      //     ./in.cue:4:16
   144    }
   145    l: (#list){
   146    }
   147    e1: (_|_){
   148      // [eval] e1: undefined field: "":
   149      //     ./in.cue:6:9
   150    }
   151    e2: (_|_){
   152      // [eval] e2: invalid operand 2 (found int, want list or struct):
   153      //     ./in.cue:7:5
   154    }
   155    e3: (_|_){
   156      // [eval] e3: invalid index true (invalid type bool):
   157      //     ./in.cue:8:5
   158      //     ./in.cue:8:8
   159    }
   160    e4: (_|_){
   161      // [eval] e4: index out of range [3] with length 3:
   162      //     ./in.cue:9:15
   163    }
   164    e5: (_|_){
   165      // [eval] e5: invalid index -1 (index must be non-negative):
   166      //     ./in.cue:10:5
   167      //     ./in.cue:10:15
   168    }
   169    e6: (_|_){
   170      // [eval] e6: index out of range [1] with length 0:
   171      //     ./in.cue:11:16
   172    }
   173    e7: (_|_){
   174      // [eval] e7: index out of range [3] with length 3:
   175      //     ./in.cue:12:15
   176    }
   177    e8: (_|_){
   178      // [eval] e8: invalid index -1 (index must be non-negative):
   179      //     ./in.cue:13:5
   180      //     ./in.cue:13:15
   181    }
   182    e9: (_|_){
   183      // [eval] e9: index out of range [1] with length 0:
   184      //     ./in.cue:14:16
   185    }
   186    def: (struct){
   187      a: (int){ 1 }
   188      #b: (int){ 3 }
   189    }
   190  }
   191  -- diff/-out/evalalpha<==>+out/eval --
   192  diff old new
   193  --- old
   194  +++ new
   195  @@ -1,9 +1,9 @@
   196   Errors:
   197  -c: invalid list index "3" (type string):
   198  +c: undefined field: "3":
   199       ./in.cue:3:20
   200   d: index out of range [0] with length 0:
   201       ./in.cue:4:16
   202  -e1: invalid list index "" (type string):
   203  +e1: undefined field: "":
   204       ./in.cue:6:9
   205   e2: invalid operand 2 (found int, want list or struct):
   206       ./in.cue:7:5
   207  @@ -15,7 +15,7 @@
   208   e5: invalid index -1 (index must be non-negative):
   209       ./in.cue:10:5
   210       ./in.cue:10:15
   211  -e6: invalid list index 1 (out of bounds):
   212  +e6: index out of range [1] with length 0:
   213       ./in.cue:11:16
   214   e7: index out of range [3] with length 3:
   215       ./in.cue:12:15
   216  @@ -22,7 +22,7 @@
   217   e8: invalid index -1 (index must be non-negative):
   218       ./in.cue:13:5
   219       ./in.cue:13:15
   220  -e9: invalid list index 1 (out of bounds):
   221  +e9: index out of range [1] with length 0:
   222       ./in.cue:14:16
   223   
   224   Result:
   225  @@ -31,7 +31,7 @@
   226     a: (int){ 2 }
   227     b: (string){ "bar" }
   228     c: (_|_){
   229  -    // [eval] c: invalid list index "3" (type string):
   230  +    // [eval] c: undefined field: "3":
   231       //     ./in.cue:3:20
   232     }
   233     d: (_|_){
   234  @@ -41,7 +41,7 @@
   235     l: (#list){
   236     }
   237     e1: (_|_){
   238  -    // [eval] e1: invalid list index "" (type string):
   239  +    // [eval] e1: undefined field: "":
   240       //     ./in.cue:6:9
   241     }
   242     e2: (_|_){
   243  @@ -63,7 +63,7 @@
   244       //     ./in.cue:10:15
   245     }
   246     e6: (_|_){
   247  -    // [eval] e6: invalid list index 1 (out of bounds):
   248  +    // [eval] e6: index out of range [1] with length 0:
   249       //     ./in.cue:11:16
   250     }
   251     e7: (_|_){
   252  @@ -76,7 +76,7 @@
   253       //     ./in.cue:13:15
   254     }
   255     e9: (_|_){
   256  -    // [eval] e9: invalid list index 1 (out of bounds):
   257  +    // [eval] e9: index out of range [1] with length 0:
   258       //     ./in.cue:14:16
   259     }
   260     def: (struct){
   261  -- diff/todo/p3 --
   262  Error messages slightly different.
   263  -- out/eval --
   264  Errors:
   265  c: invalid list index "3" (type string):
   266      ./in.cue:3:20
   267  d: index out of range [0] with length 0:
   268      ./in.cue:4:16
   269  e1: invalid list index "" (type string):
   270      ./in.cue:6:9
   271  e2: invalid operand 2 (found int, want list or struct):
   272      ./in.cue:7:5
   273  e3: invalid index true (invalid type bool):
   274      ./in.cue:8:5
   275      ./in.cue:8:8
   276  e4: index out of range [3] with length 3:
   277      ./in.cue:9:15
   278  e5: invalid index -1 (index must be non-negative):
   279      ./in.cue:10:5
   280      ./in.cue:10:15
   281  e6: invalid list index 1 (out of bounds):
   282      ./in.cue:11:16
   283  e7: index out of range [3] with length 3:
   284      ./in.cue:12:15
   285  e8: invalid index -1 (index must be non-negative):
   286      ./in.cue:13:5
   287      ./in.cue:13:15
   288  e9: invalid list index 1 (out of bounds):
   289      ./in.cue:14:16
   290  
   291  Result:
   292  (_|_){
   293    // [eval]
   294    a: (int){ 2 }
   295    b: (string){ "bar" }
   296    c: (_|_){
   297      // [eval] c: invalid list index "3" (type string):
   298      //     ./in.cue:3:20
   299    }
   300    d: (_|_){
   301      // [eval] d: index out of range [0] with length 0:
   302      //     ./in.cue:4:16
   303    }
   304    l: (#list){
   305    }
   306    e1: (_|_){
   307      // [eval] e1: invalid list index "" (type string):
   308      //     ./in.cue:6:9
   309    }
   310    e2: (_|_){
   311      // [eval] e2: invalid operand 2 (found int, want list or struct):
   312      //     ./in.cue:7:5
   313    }
   314    e3: (_|_){
   315      // [eval] e3: invalid index true (invalid type bool):
   316      //     ./in.cue:8:5
   317      //     ./in.cue:8:8
   318    }
   319    e4: (_|_){
   320      // [eval] e4: index out of range [3] with length 3:
   321      //     ./in.cue:9:15
   322    }
   323    e5: (_|_){
   324      // [eval] e5: invalid index -1 (index must be non-negative):
   325      //     ./in.cue:10:5
   326      //     ./in.cue:10:15
   327    }
   328    e6: (_|_){
   329      // [eval] e6: invalid list index 1 (out of bounds):
   330      //     ./in.cue:11:16
   331    }
   332    e7: (_|_){
   333      // [eval] e7: index out of range [3] with length 3:
   334      //     ./in.cue:12:15
   335    }
   336    e8: (_|_){
   337      // [eval] e8: invalid index -1 (index must be non-negative):
   338      //     ./in.cue:13:5
   339      //     ./in.cue:13:15
   340    }
   341    e9: (_|_){
   342      // [eval] e9: invalid list index 1 (out of bounds):
   343      //     ./in.cue:14:16
   344    }
   345    def: (struct){
   346      a: (int){ 1 }
   347      #b: (int){ 3 }
   348    }
   349  }