...

Text file src/cuelang.org/go/cue/testdata/cycle/051_resolved_self-reference_cycles_with_disjunction.txtar

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

     1#name: resolved self-reference cycles with disjunction
     2#evalPartial
     3
     4// TODO(cycle)
     5//
     6// Some of these examples used to work, but the changes corresponding to this
     7// addition, it ceased to do so. Fixing these cycle issues seemed more
     8// important than keeping this esoteric case working, which was already broken
     9// in the last release anyway.
    10//
    11// Reproducer of underlying problem. Still works, but triggers unexpected
    12// condition.
    13//
    14// xb1: xb2
    15// xb2: xb3
    16// xb3: xb2 + 0
    17
    18-- in.cue --
    19// The second disjunct in xa1 is not resolvable and can be
    20// eliminated:
    21//   xa4 & 9
    22//   (xa2 + 2) & 9
    23//   ((xa3 + 2) + 2) & 9
    24//   (((6 & xa1-2) + 2) + 2) & 9
    25//   ((6 + 2) + 2) & 9 // 6 == xa1-2
    26//   10 & 9 => _|_
    27// The remaining values resolve.
    28xa1: (xa2 & 8) | (xa4 & 9)
    29xa2: xa3 + 2
    30xa3: 6 & xa1-2
    31xa4: xa2 + 2
    32
    33xb1: (xb2 & 8) | (xb4 & 9)
    34xb2: xb3 + 2
    35xb3: (6 & (xb1 - 2)) | (xb4 & 9)
    36xb4: xb2 + 2
    37
    38// Another variant with more disjunctions. xc1 remains with two
    39// possibilities. Technically, only the first value is valid.
    40// However, to fully determine that, all options of the remaining
    41// disjunction will have to be evaluated algebraically, which is
    42// not done.
    43xc1: xc2 & 8 | xc4 & 9 | xc5 & 9
    44xc2: xc3 + 2
    45xc3: 6 & xc1-2
    46xc4: xc2 + 1
    47xc5: xc2 + 2
    48
    49// The below is resolved by setting xd1 explicitly.
    50xd1: xd2 & 8 | xd4 & 9 | xd5 & 9
    51xd2: xd3 + 2
    52xd3: 6 & xd1-2
    53xd4: xd2 + 1
    54xd5: xd2 + 2
    55xd1: 8
    56
    57// The below is resolved by setting xd1 explicitly to the wrong
    58// value, resulting in an error.
    59xe1: xe2 & 8 | xe4 & 9 | xe5 & 9
    60xe2: xe3 + 2
    61xe3: 6 & xe1-2
    62xe4: xe2 + 1
    63xe5: xe2 + 2
    64xe1: 9
    65
    66xf1: xf2 & 8 | xf4 & 9
    67xf2: xf3 + 2
    68xf3: 6 & xf1-2 | xf4 & 9
    69xf4: xf2 + 2
    70
    71z1: z2+1 | z3+5 // +3 for fun
    72z2: z3 + 2
    73z3: z1 - 3
    74z3: 8
    75-- out/def --
    76// The second disjunct in xa1 is not resolvable and can be
    77// eliminated:
    78//   xa4 & 9
    79//   (xa2 + 2) & 9
    80//   ((xa3 + 2) + 2) & 9
    81//   (((6 & xa1-2) + 2) + 2) & 9
    82//   ((6 + 2) + 2) & 9 // 6 == xa1-2
    83//   10 & 9 => _|_
    84// The remaining values resolve.
    85xa1: 8
    86xa2: 8
    87xa4: 10
    88xa3: 6
    89
    90// The second disjunct in xb4 can be eliminated as both disjuncts
    91// of xb3 result in an incompatible sum when substituted.
    92xb1: 8
    93xb2: 8
    94xb4: 10
    95xb3: 6
    96
    97// Another variant with more disjunctions. xc1 remains with two
    98// possibilities. Technically, only the first value is valid.
    99// However, to fully determine that, all options of the remaining
   100// disjunction will have to be evaluated algebraically, which is
   101// not done.
   102xc1: xc2 & 8 | xc4 & 9 | xc5 & 9
   103xc2: xc3 + 2
   104xc4: xc2 + 1
   105xc5: xc2 + 2
   106xc3: 6 & xc1-2
   107
   108// The above is resolved by setting xd1 explicitly.
   109xd1: 8
   110xd2: 8
   111xd4: 9
   112xd5: 10
   113xd3: 6
   114
   115// The above is resolved by setting xd1 explicitly to the wrong
   116// value, resulting in an error.
   117xe1: _|_ // conflicting values 6 and 7
   118xe2: _|_ // conflicting values 6 and 7
   119xe4: _|_ // conflicting values 6 and 7
   120xe5: _|_ // conflicting values 6 and 7
   121xe3: _|_ // conflicting values 6 and 7
   122
   123// Only one solution.
   124xf1: 8
   125xf2: 8
   126xf4: 10
   127xf3: 6
   128z1:  z2+1 | z3+5
   129z2:  z3 + 2
   130z3:  z1-3 & 8
   131-- out/legacy-debug --
   132<0>{xa1: 8, xa2: 8, xa4: 10, xa3: 6, xb1: 8, xb2: 8, xb4: 10, xb3: 6, xc1: ((<1>.xc2 & 8) | (<1>.xc4 & 9) | (<1>.xc5 & 9)), xc2: (<1>.xc3 + 2), xc4: (<1>.xc2 + 1), xc5: (<1>.xc2 + 2), xc3: (6 & (<1>.xc1 - 2)), xd1: 8, xd2: 8, xd4: 9, xd5: 10, xd3: 6, xe1: _|_((6 & 7):conflicting values 6 and 7), xe2: _|_((6 & 7):conflicting values 6 and 7), xe4: _|_((6 & 7):conflicting values 6 and 7), xe5: _|_((6 & 7):conflicting values 6 and 7), xe3: _|_((6 & 7):conflicting values 6 and 7), xf1: 8, xf2: 8, xf4: 10, xf3: 6, z1: ((<1>.z2 + 1) | (<1>.z3 + 5)), z2: (<1>.z3 + 2), z3: ((<1>.z1 - 3) & 8)}
   133-- out/compile --
   134--- in.cue
   135{
   136  xa1: ((〈0;xa2〉 & 8)|(〈0;xa4〉 & 9))
   137  xa2: (〈0;xa3〉 + 2)
   138  xa3: (6 & (〈0;xa1〉 - 2))
   139  xa4: (〈0;xa2〉 + 2)
   140  xb1: ((〈0;xb2〉 & 8)|(〈0;xb4〉 & 9))
   141  xb2: (〈0;xb3〉 + 2)
   142  xb3: ((6 & (〈0;xb1〉 - 2))|(〈0;xb4〉 & 9))
   143  xb4: (〈0;xb2〉 + 2)
   144  xc1: ((〈0;xc2〉 & 8)|(〈0;xc4〉 & 9)|(〈0;xc5〉 & 9))
   145  xc2: (〈0;xc3〉 + 2)
   146  xc3: (6 & (〈0;xc1〉 - 2))
   147  xc4: (〈0;xc2〉 + 1)
   148  xc5: (〈0;xc2〉 + 2)
   149  xd1: ((〈0;xd2〉 & 8)|(〈0;xd4〉 & 9)|(〈0;xd5〉 & 9))
   150  xd2: (〈0;xd3〉 + 2)
   151  xd3: (6 & (〈0;xd1〉 - 2))
   152  xd4: (〈0;xd2〉 + 1)
   153  xd5: (〈0;xd2〉 + 2)
   154  xd1: 8
   155  xe1: ((〈0;xe2〉 & 8)|(〈0;xe4〉 & 9)|(〈0;xe5〉 & 9))
   156  xe2: (〈0;xe3〉 + 2)
   157  xe3: (6 & (〈0;xe1〉 - 2))
   158  xe4: (〈0;xe2〉 + 1)
   159  xe5: (〈0;xe2〉 + 2)
   160  xe1: 9
   161  xf1: ((〈0;xf2〉 & 8)|(〈0;xf4〉 & 9))
   162  xf2: (〈0;xf3〉 + 2)
   163  xf3: ((6 & (〈0;xf1〉 - 2))|(〈0;xf4〉 & 9))
   164  xf4: (〈0;xf2〉 + 2)
   165  z1: ((〈0;z2〉 + 1)|(〈0;z3〉 + 5))
   166  z2: (〈0;z3〉 + 2)
   167  z3: (〈0;z1〉 - 3)
   168  z3: 8
   169}
   170-- out/eval/stats --
   171Leaks:  0
   172Freed:  52
   173Reused: 44
   174Allocs: 8
   175Retain: 24
   176
   177Unifications: 31
   178Conjuncts:    128
   179Disjuncts:    60
   180-- out/eval --
   181Errors:
   182xe3: conflicting values 7 and 6:
   183    ./in.cue:43:6
   184    ./in.cue:43:10
   185
   186Result:
   187(_|_){
   188  // [eval]
   189  xa1: (int){ 8 }
   190  xa2: (int){ 8 }
   191  xa3: (int){ 6 }
   192  xa4: (int){ 10 }
   193  xb1: (_|_){
   194    // [incomplete] xb1: 2 errors in empty disjunction:
   195    // xb1: unresolved disjunction 6 | 9 (type int):
   196    //     ./in.cue:16:6
   197    // xb2: unresolved disjunction 6 | 9 (type int):
   198    //     ./in.cue:16:6
   199  }
   200  xb2: (_|_){
   201    // [incomplete] xb2: unresolved disjunction 6 | 9 (type int):
   202    //     ./in.cue:16:6
   203  }
   204  xb3: (int){ |((int){ 6 }, (int){ 9 }) }
   205  xb4: (_|_){
   206    // [incomplete] xb2: unresolved disjunction 6 | 9 (type int):
   207    //     ./in.cue:16:6
   208  }
   209  xc1: (int){ |((int){ 8 }, (int){ 9 }) }
   210  xc2: (int){ 8 }
   211  xc3: (_|_){
   212    // [incomplete] xc3: unresolved disjunction 8 | 9 (type int):
   213    //     ./in.cue:27:10
   214  }
   215  xc4: (int){ 9 }
   216  xc5: (int){ 10 }
   217  xd1: (int){ 8 }
   218  xd2: (int){ 8 }
   219  xd3: (int){ 6 }
   220  xd4: (int){ 9 }
   221  xd5: (int){ 10 }
   222  xe1: (int){ 9 }
   223  xe2: (int){ 8 }
   224  xe3: (_|_){
   225    // [eval] xe3: conflicting values 7 and 6:
   226    //     ./in.cue:43:6
   227    //     ./in.cue:43:10
   228  }
   229  xe4: (int){ 9 }
   230  xe5: (int){ 10 }
   231  xf1: (_|_){
   232    // [incomplete] xf1: 2 errors in empty disjunction:
   233    // xf1: unresolved disjunction 6 | 9 (type int):
   234    //     ./in.cue:49:6
   235    // xf2: unresolved disjunction 6 | 9 (type int):
   236    //     ./in.cue:49:6
   237  }
   238  xf2: (_|_){
   239    // [incomplete] xf2: unresolved disjunction 6 | 9 (type int):
   240    //     ./in.cue:49:6
   241  }
   242  xf3: (int){ |((int){ 6 }, (int){ 9 }) }
   243  xf4: (_|_){
   244    // [incomplete] xf2: unresolved disjunction 6 | 9 (type int):
   245    //     ./in.cue:49:6
   246  }
   247  z1: (int){ |((int){ 11 }, (int){ 13 }) }
   248  z2: (int){ 10 }
   249  z3: (_|_){
   250    // [incomplete] z3: unresolved disjunction 11 | 13 (type int):
   251    //     ./in.cue:55:5
   252  }
   253}

View as plain text