...

Text file src/cuelang.org/go/cue/testdata/basicrewrite/012_selecting.txtar

Documentation: cuelang.org/go/cue/testdata/basicrewrite

     1# DO NOT EDIT; generated by go run testdata/gen.go
     2#
     3#name: selecting
     4#evalPartial
     5-- in.cue --
     6obj: {a: 1, b: 2}
     7index:  {a: 1, b:     2}["b"]
     8mulidx: {a: 1, b: {a: 1, b: 3}}["b"]["b"]
     9e:      {a: 1}[4]
    10f:      {a: 1}.b
    11g:      {a: 1}["b"]
    12h:      [3].b
    13-- out/def --
    14obj: {
    15	a: 1
    16	b: 2
    17}
    18index:  2
    19mulidx: 3
    20e:      _|_ // invalid struct index 4 (type int)
    21f:      {
    22	a: 1
    23}.b
    24g: {
    25	a: 1
    26}["b"]
    27h: _|_ // invalid operation: [3].b (type list does not support selection)
    28-- out/legacy-debug --
    29<0>{obj: <1>{a: 1, b: 2}, index: 2, mulidx: 3, e: _|_(4:invalid struct index 4 (type int)), f: <2>{a: 1}.b, g: <3>{a: 1}["b"], h: _|_([3]:invalid operation: [3].b (type list does not support selection))}
    30-- out/compile --
    31--- in.cue
    32{
    33  obj: {
    34    a: 1
    35    b: 2
    36  }
    37  index: {
    38    a: 1
    39    b: 2
    40  }["b"]
    41  mulidx: {
    42    a: 1
    43    b: {
    44      a: 1
    45      b: 3
    46    }
    47  }["b"]["b"]
    48  e: {
    49    a: 1
    50  }[4]
    51  f: {
    52    a: 1
    53  }.b
    54  g: {
    55    a: 1
    56  }["b"]
    57  h: [
    58    3,
    59  ].b
    60}
    61-- out/eval/stats --
    62Leaks:  17
    63Freed:  10
    64Reused: 8
    65Allocs: 19
    66Retain: 17
    67
    68Unifications: 27
    69Conjuncts:    35
    70Disjuncts:    25
    71-- out/evalalpha --
    72Errors:
    73e: index out of range [4] with length 0:
    74    ./in.cue:4:16
    75h: undefined field: b:
    76    ./in.cue:7:13
    77
    78Result:
    79(_|_){
    80  // [eval]
    81  obj: (struct){
    82    a: (int){ 1 }
    83    b: (int){ 2 }
    84  }
    85  index: (int){ 2 }
    86  mulidx: (int){ 3 }
    87  e: (_|_){
    88    // [eval] e: index out of range [4] with length 0:
    89    //     ./in.cue:4:16
    90  }
    91  f: (_|_){
    92    // [incomplete] f: undefined field: b:
    93    //     ./in.cue:5:16
    94  }
    95  g: (_|_){
    96    // [incomplete] g: undefined field: b:
    97    //     ./in.cue:6:16
    98  }
    99  h: (_|_){
   100    // [eval] h: undefined field: b:
   101    //     ./in.cue:7:13
   102  }
   103}
   104-- diff/-out/evalalpha<==>+out/eval --
   105diff old new
   106--- old
   107+++ new
   108@@ -1,7 +1,7 @@
   109 Errors:
   110-e: invalid struct selector 4 (type int):
   111+e: index out of range [4] with length 0:
   112     ./in.cue:4:16
   113-h: invalid list index b (type string):
   114+h: undefined field: b:
   115     ./in.cue:7:13
   116 
   117 Result:
   118@@ -14,7 +14,7 @@
   119   index: (int){ 2 }
   120   mulidx: (int){ 3 }
   121   e: (_|_){
   122-    // [eval] e: invalid struct selector 4 (type int):
   123+    // [eval] e: index out of range [4] with length 0:
   124     //     ./in.cue:4:16
   125   }
   126   f: (_|_){
   127@@ -26,7 +26,7 @@
   128     //     ./in.cue:6:16
   129   }
   130   h: (_|_){
   131-    // [eval] h: invalid list index b (type string):
   132+    // [eval] h: undefined field: b:
   133     //     ./in.cue:7:13
   134   }
   135 }
   136-- diff/explanation --
   137Better error message for undefined field in new.
   138Other error got worse, but this is covered elsewhere.
   139-- out/eval --
   140Errors:
   141e: invalid struct selector 4 (type int):
   142    ./in.cue:4:16
   143h: invalid list index b (type string):
   144    ./in.cue:7:13
   145
   146Result:
   147(_|_){
   148  // [eval]
   149  obj: (struct){
   150    a: (int){ 1 }
   151    b: (int){ 2 }
   152  }
   153  index: (int){ 2 }
   154  mulidx: (int){ 3 }
   155  e: (_|_){
   156    // [eval] e: invalid struct selector 4 (type int):
   157    //     ./in.cue:4:16
   158  }
   159  f: (_|_){
   160    // [incomplete] f: undefined field: b:
   161    //     ./in.cue:5:16
   162  }
   163  g: (_|_){
   164    // [incomplete] g: undefined field: b:
   165    //     ./in.cue:6:16
   166  }
   167  h: (_|_){
   168    // [eval] h: invalid list index b (type string):
   169    //     ./in.cue:7:13
   170  }
   171}

View as plain text