cuelang.org/go@v0.13.0/cue/testdata/resolve/018_slice.txtar (about)

     1  #name: slice
     2  #evalPartial
     3  -- in.cue --
     4  a:  [2][0:0]
     5  b:  [0][1:1]
     6  e1: [][1:1]
     7  e2: [0][-1:0]
     8  e3: [0][1:0]
     9  e4: [0][1:2]
    10  e5: 4[1:2]
    11  e6: [2]["":]
    12  e7: [2][:"9"]
    13  -- out/def --
    14  a: []
    15  b: []
    16  e1: _|_ // slice bounds out of range
    17  e2: _|_ // negative slice index
    18  e3: _|_ // invalid slice index: 1 > 0
    19  e4: _|_ // slice bounds out of range
    20  e5: _|_ // cannot slice 4 (type int)
    21  e6: _|_ // invalid slice index "" (type string)
    22  e7: _|_ // invalid slice index "9" (type string)
    23  -- out/legacy-debug --
    24  <0>{a: [], b: [], e1: _|_(1:slice bounds out of range), e2: _|_([0]:negative slice index), e3: _|_([0]:invalid slice index: 1 > 0), e4: _|_(2:slice bounds out of range), e5: _|_(4:cannot slice 4 (type int)), e6: _|_("":invalid slice index "" (type string)), e7: _|_("9":invalid slice index "9" (type string))}
    25  -- out/compile --
    26  --- in.cue
    27  {
    28    a: [
    29      2,
    30    ][0:0]
    31    b: [
    32      0,
    33    ][1:1]
    34    e1: [][1:1]
    35    e2: [
    36      0,
    37    ][-1:0]
    38    e3: [
    39      0,
    40    ][1:0]
    41    e4: [
    42      0,
    43    ][1:2]
    44    e5: 4[1:2]
    45    e6: [
    46      2,
    47    ]["":]
    48    e7: [
    49      2,
    50    ][:"9"]
    51  }
    52  -- out/eval/stats --
    53  Leaks:  8
    54  Freed:  10
    55  Reused: 8
    56  Allocs: 10
    57  Retain: 8
    58  
    59  Unifications: 18
    60  Conjuncts:    18
    61  Disjuncts:    18
    62  -- out/eval --
    63  Errors:
    64  e1: index 1 out of range:
    65      ./in.cue:3:5
    66  e2: cannot convert negative number to uint64:
    67      ./in.cue:4:5
    68  e3: invalid slice index: 1 > 0:
    69      ./in.cue:5:5
    70  e4: index 2 out of range:
    71      ./in.cue:6:5
    72  e5: cannot slice 4 (type int):
    73      ./in.cue:7:5
    74  e6: cannot use "" (type string) as type int in slice index:
    75      ./in.cue:8:5
    76      ./in.cue:8:9
    77  e7: cannot use "9" (type string) as type int in slice index:
    78      ./in.cue:9:5
    79      ./in.cue:9:10
    80  
    81  Result:
    82  (_|_){
    83    // [eval]
    84    a: (#list){
    85    }
    86    b: (#list){
    87    }
    88    e1: (_|_){
    89      // [eval] e1: index 1 out of range:
    90      //     ./in.cue:3:5
    91    }
    92    e2: (_|_){
    93      // [eval] e2: cannot convert negative number to uint64:
    94      //     ./in.cue:4:5
    95    }
    96    e3: (_|_){
    97      // [eval] e3: invalid slice index: 1 > 0:
    98      //     ./in.cue:5:5
    99    }
   100    e4: (_|_){
   101      // [eval] e4: index 2 out of range:
   102      //     ./in.cue:6:5
   103    }
   104    e5: (_|_){
   105      // [eval] e5: cannot slice 4 (type int):
   106      //     ./in.cue:7:5
   107    }
   108    e6: (_|_){
   109      // [eval] e6: cannot use "" (type string) as type int in slice index:
   110      //     ./in.cue:8:5
   111      //     ./in.cue:8:9
   112    }
   113    e7: (_|_){
   114      // [eval] e7: cannot use "9" (type string) as type int in slice index:
   115      //     ./in.cue:9:5
   116      //     ./in.cue:9:10
   117    }
   118  }