cuelang.org/go@v0.10.1/cue/testdata/cycle/inline.txtar (about)

     1  -- x.cue --
     2  // variants of fib
     3  
     4  inline: small: {
     5  	f: {
     6  		n: int
     7  		out: (f & {"n": n - 1}).out
     8  	}
     9  }
    10  
    11  inline: medium: {
    12  	f2:  (f & {n: 2}).out
    13  	fRec: {nn: int, out: (f & {n: nn}).out}
    14  	f: {
    15  		n: int
    16  		out: (fRec & {nn: n - 1}).out
    17  	}
    18  }
    19  
    20  inline: patterns: {
    21  	f: n: (f & {n: {}}).n
    22  	f: n: {}
    23  	[string]: {n: {}}
    24  	f: [string]: {}
    25  	f: {}
    26  }
    27  
    28  inline: acrossFields: fail1: {
    29  	f: {
    30  		in:  number
    31  		out: in + 1
    32  	}
    33  	k00: 0
    34  	k10: (f & {in: k00}).out
    35  	k20: (f & {in: k10}).out
    36  	k30: (f & {in: k20}).out
    37  
    38  	// invalid recursion is here.
    39  	k10: (f & {in: k30}).out
    40  }
    41  
    42  // Issue #2163
    43  inline: acrossFields: ok1: {
    44  	f: {
    45  		in:  number
    46  		out: in
    47  	}
    48  	k00: 0
    49  	k10: (f & {in: k00}).out
    50  	k20: (f & {in: k10}).out
    51  	k30: (f & {in: k20}).out
    52  
    53  	// TODO: what is correct behavior here.
    54  	// This is borderline okay.
    55  	k10: (f & {in: k30}).out
    56  }
    57  -- out/compile --
    58  --- x.cue
    59  {
    60    inline: {
    61      small: {
    62        f: {
    63          n: int
    64          out: (〈1;f〉 & {
    65            n: (〈1;n〉 - 1)
    66          }).out
    67        }
    68      }
    69    }
    70    inline: {
    71      medium: {
    72        f2: (〈0;f〉 & {
    73          n: 2
    74        }).out
    75        fRec: {
    76          nn: int
    77          out: (〈1;f〉 & {
    78            n: 〈1;nn〉
    79          }).out
    80        }
    81        f: {
    82          n: int
    83          out: (〈1;fRec〉 & {
    84            nn: (〈1;n〉 - 1)
    85          }).out
    86        }
    87      }
    88    }
    89    inline: {
    90      patterns: {
    91        f: {
    92          n: (〈1;f〉 & {
    93            n: {}
    94          }).n
    95        }
    96        f: {
    97          n: {}
    98        }
    99        [string]: {
   100          n: {}
   101        }
   102        f: {
   103          [string]: {}
   104        }
   105        f: {}
   106      }
   107    }
   108    inline: {
   109      acrossFields: {
   110        fail1: {
   111          f: {
   112            in: number
   113            out: (〈0;in〉 + 1)
   114          }
   115          k00: 0
   116          k10: (〈0;f〉 & {
   117            in: 〈1;k00〉
   118          }).out
   119          k20: (〈0;f〉 & {
   120            in: 〈1;k10〉
   121          }).out
   122          k30: (〈0;f〉 & {
   123            in: 〈1;k20〉
   124          }).out
   125          k10: (〈0;f〉 & {
   126            in: 〈1;k30〉
   127          }).out
   128        }
   129      }
   130    }
   131    inline: {
   132      acrossFields: {
   133        ok1: {
   134          f: {
   135            in: number
   136            out: 〈0;in〉
   137          }
   138          k00: 0
   139          k10: (〈0;f〉 & {
   140            in: 〈1;k00〉
   141          }).out
   142          k20: (〈0;f〉 & {
   143            in: 〈1;k10〉
   144          }).out
   145          k30: (〈0;f〉 & {
   146            in: 〈1;k20〉
   147          }).out
   148          k10: (〈0;f〉 & {
   149            in: 〈1;k30〉
   150          }).out
   151        }
   152      }
   153    }
   154  }
   155  -- out/eval/stats --
   156  Leaks:  247
   157  Freed:  141
   158  Reused: 136
   159  Allocs: 252
   160  Retain: 834
   161  
   162  Unifications: 388
   163  Conjuncts:    1307
   164  Disjuncts:    707
   165  -- out/eval --
   166  Errors:
   167  structural cycle:
   168      ./x.cue:6:9
   169  structural cycle:
   170      ./x.cue:15:9
   171  structural cycle:
   172      ./x.cue:20:9
   173  in: structural cycle:
   174      ./x.cue:30:8
   175  
   176  Result:
   177  (_|_){
   178    // [structural cycle]
   179    inline: (_|_){
   180      // [structural cycle]
   181      small: (_|_){
   182        // [structural cycle]
   183        f: (_|_){
   184          // [structural cycle]
   185          n: (int){ int }
   186          out: (_|_){
   187            // [structural cycle] structural cycle:
   188            //     ./x.cue:6:9
   189          }
   190        }
   191      }
   192      medium: (_|_){
   193        // [structural cycle]
   194        f2: (_|_){
   195          // [structural cycle] structural cycle:
   196          //     ./x.cue:15:9
   197        }
   198        fRec: (_|_){
   199          // [structural cycle]
   200          nn: (int){ int }
   201          out: (_|_){
   202            // [structural cycle] structural cycle:
   203            //     ./x.cue:15:9
   204          }
   205        }
   206        f: (_|_){
   207          // [structural cycle]
   208          n: (int){ int }
   209          out: (_|_){
   210            // [structural cycle] structural cycle:
   211            //     ./x.cue:15:9
   212          }
   213        }
   214      }
   215      patterns: (_|_){
   216        // [structural cycle]
   217        f: (_|_){
   218          // [structural cycle]
   219          n: (_|_){
   220            // [structural cycle] structural cycle:
   221            //     ./x.cue:20:9
   222          }
   223        }
   224      }
   225      acrossFields: (_|_){
   226        // [structural cycle]
   227        fail1: (_|_){
   228          // [structural cycle]
   229          f: (struct){
   230            in: (number){ number }
   231            out: (_|_){
   232              // [incomplete] inline.acrossFields.fail1.f.out: non-concrete value number in operand to +:
   233              //     ./x.cue:30:8
   234              //     ./x.cue:29:8
   235            }
   236          }
   237          k00: (int){ 0 }
   238          k10: (_|_){
   239            // [structural cycle] in: structural cycle:
   240            //     ./x.cue:30:8
   241          }
   242          k20: (_|_){
   243            // [structural cycle] in: structural cycle:
   244            //     ./x.cue:30:8
   245          }
   246          k30: (_|_){
   247            // [structural cycle] in: structural cycle:
   248            //     ./x.cue:30:8
   249          }
   250        }
   251        ok1: (struct){
   252          f: (struct){
   253            in: (number){ number }
   254            out: (number){ number }
   255          }
   256          k00: (int){ 0 }
   257          k10: (int){ 0 }
   258          k20: (int){ 0 }
   259          k30: (int){ 0 }
   260        }
   261      }
   262    }
   263  }
   264  -- out/evalalpha --
   265  Errors:
   266  structural cycle:
   267      ./x.cue:6:9
   268  structural cycle:
   269      ./x.cue:12:24
   270  structural cycle:
   271      ./x.cue:15:9
   272  structural cycle:
   273      ./x.cue:20:9
   274  in: structural cycle:
   275      ./x.cue:34:17
   276  in: structural cycle:
   277      ./x.cue:35:17
   278  in: structural cycle:
   279      ./x.cue:38:17
   280  in: structural cycle:
   281      ./x.cue:49:17
   282  in: structural cycle:
   283      ./x.cue:50:17
   284  in: structural cycle:
   285      ./x.cue:54:17
   286  
   287  Result:
   288  (_|_){
   289    // [structural cycle]
   290    inline: (_|_){
   291      // [structural cycle]
   292      small: (_|_){
   293        // [structural cycle]
   294        f: (_|_){
   295          // [structural cycle]
   296          n: (int){ int }
   297          out: (_|_){
   298            // [structural cycle] structural cycle:
   299            //     ./x.cue:6:9
   300          }
   301        }
   302      }
   303      medium: (_|_){
   304        // [structural cycle]
   305        f2: (_|_){
   306          // [structural cycle] structural cycle:
   307          //     ./x.cue:12:24
   308        }
   309        fRec: (_|_){
   310          // [structural cycle]
   311          nn: (int){ int }
   312          out: (_|_){
   313            // [structural cycle] structural cycle:
   314            //     ./x.cue:12:24
   315          }
   316        }
   317        f: (_|_){
   318          // [structural cycle]
   319          n: (int){ int }
   320          out: (_|_){
   321            // [structural cycle] structural cycle:
   322            //     ./x.cue:15:9
   323          }
   324        }
   325      }
   326      patterns: (_|_){
   327        // [structural cycle]
   328        f: (_|_){
   329          // [structural cycle]
   330          n: (_|_){
   331            // [structural cycle] structural cycle:
   332            //     ./x.cue:20:9
   333          }
   334        }
   335      }
   336      acrossFields: (_|_){
   337        // [structural cycle]
   338        fail1: (_|_){
   339          // [structural cycle]
   340          f: (struct){
   341            in: (number){ number }
   342            out: (_|_){
   343              // [incomplete] inline.acrossFields.fail1.f.out: non-concrete value number in operand to +:
   344              //     ./x.cue:30:8
   345              //     ./x.cue:29:8
   346            }
   347          }
   348          k00: (int){ 0 }
   349          k10: (_|_){
   350            // [structural cycle] in: structural cycle:
   351            //     ./x.cue:38:17
   352          }
   353          k20: (_|_){
   354            // [structural cycle] in: structural cycle:
   355            //     ./x.cue:34:17
   356          }
   357          k30: (_|_){
   358            // [structural cycle] in: structural cycle:
   359            //     ./x.cue:35:17
   360          }
   361        }
   362        ok1: (_|_){
   363          // [structural cycle]
   364          f: (struct){
   365            in: (number){ number }
   366            out: (number){ number }
   367          }
   368          k00: (int){ 0 }
   369          k10: (_|_){
   370            // [structural cycle] in: structural cycle:
   371            //     ./x.cue:54:17
   372          }
   373          k20: (_|_){
   374            // [structural cycle] in: structural cycle:
   375            //     ./x.cue:49:17
   376          }
   377          k30: (_|_){
   378            // [structural cycle] in: structural cycle:
   379            //     ./x.cue:50:17
   380          }
   381        }
   382      }
   383    }
   384  }
   385  -- diff/-out/evalalpha<==>+out/eval --
   386  diff old new
   387  --- old
   388  +++ new
   389  @@ -2,11 +2,23 @@
   390   structural cycle:
   391       ./x.cue:6:9
   392   structural cycle:
   393  +    ./x.cue:12:24
   394  +structural cycle:
   395       ./x.cue:15:9
   396   structural cycle:
   397       ./x.cue:20:9
   398   in: structural cycle:
   399  -    ./x.cue:30:8
   400  +    ./x.cue:34:17
   401  +in: structural cycle:
   402  +    ./x.cue:35:17
   403  +in: structural cycle:
   404  +    ./x.cue:38:17
   405  +in: structural cycle:
   406  +    ./x.cue:49:17
   407  +in: structural cycle:
   408  +    ./x.cue:50:17
   409  +in: structural cycle:
   410  +    ./x.cue:54:17
   411   
   412   Result:
   413   (_|_){
   414  @@ -28,7 +40,7 @@
   415         // [structural cycle]
   416         f2: (_|_){
   417           // [structural cycle] structural cycle:
   418  -        //     ./x.cue:15:9
   419  +        //     ./x.cue:12:24
   420         }
   421         fRec: (_|_){
   422           // [structural cycle]
   423  @@ -35,7 +47,7 @@
   424           nn: (int){ int }
   425           out: (_|_){
   426             // [structural cycle] structural cycle:
   427  -          //     ./x.cue:15:9
   428  +          //     ./x.cue:12:24
   429           }
   430         }
   431         f: (_|_){
   432  @@ -72,26 +84,36 @@
   433           k00: (int){ 0 }
   434           k10: (_|_){
   435             // [structural cycle] in: structural cycle:
   436  -          //     ./x.cue:30:8
   437  -        }
   438  -        k20: (_|_){
   439  -          // [structural cycle] in: structural cycle:
   440  -          //     ./x.cue:30:8
   441  -        }
   442  -        k30: (_|_){
   443  -          // [structural cycle] in: structural cycle:
   444  -          //     ./x.cue:30:8
   445  -        }
   446  -      }
   447  -      ok1: (struct){
   448  +          //     ./x.cue:38:17
   449  +        }
   450  +        k20: (_|_){
   451  +          // [structural cycle] in: structural cycle:
   452  +          //     ./x.cue:34:17
   453  +        }
   454  +        k30: (_|_){
   455  +          // [structural cycle] in: structural cycle:
   456  +          //     ./x.cue:35:17
   457  +        }
   458  +      }
   459  +      ok1: (_|_){
   460  +        // [structural cycle]
   461           f: (struct){
   462             in: (number){ number }
   463             out: (number){ number }
   464           }
   465           k00: (int){ 0 }
   466  -        k10: (int){ 0 }
   467  -        k20: (int){ 0 }
   468  -        k30: (int){ 0 }
   469  +        k10: (_|_){
   470  +          // [structural cycle] in: structural cycle:
   471  +          //     ./x.cue:54:17
   472  +        }
   473  +        k20: (_|_){
   474  +          // [structural cycle] in: structural cycle:
   475  +          //     ./x.cue:49:17
   476  +        }
   477  +        k30: (_|_){
   478  +          // [structural cycle] in: structural cycle:
   479  +          //     ./x.cue:50:17
   480  +        }
   481         }
   482       }
   483     }
   484  -- diff/todo/p2 --
   485  One test now fails. Given TODO, this may be okay.
   486  This does break Issue #2163.