cuelang.org/go@v0.13.0/cue/testdata/cycle/inline_non_recursive.txtar (about)

     1  -- in.cue --
     2  // All these should pass. These look like recursive inlined calls, but they are
     3  // not.
     4  
     5  ok1: {
     6  	f: {
     7  		in:  number
     8  		out: in
     9  	}
    10  	k00: 0
    11  	k10: (f & {in: k00}).out
    12  	k20: (f & {in: k10}).out
    13  	k30: (f & {in: k20}).out
    14  }
    15  
    16  ok2: {
    17  	f: {
    18  		in:  number
    19  		out: in
    20  	}
    21  	k00: 0
    22  	k10: {(f & {in: k00}).out}
    23  	k20: {(f & {in: k10}).out}
    24  	k30: {(f & {in: k20}).out}
    25  }
    26  
    27  ok3: {
    28  	f: {
    29  		in:  number
    30  		out: in
    31  	}
    32  	k00: 0
    33  	k10: {close((f & {in: k00})).out}
    34  	k20: {close((f & {in: k10})).out}
    35  	k30: {close((f & {in: k20})).out}
    36  }
    37  
    38  ok4: {
    39  	f: {
    40  		in:  number
    41  		out: in
    42  	}
    43  	k00: 0
    44  	k10: {out: {(f & {in: k00}).out}}.out
    45  	k20: {out: {(f & {in: k10}).out}}.out
    46  	k30: {out: {(f & {in: k20}).out}}.out
    47  }
    48  
    49  // Issue #1708
    50  issue1708: {
    51  	#add10: {
    52  		in: number
    53  		a10: { i: in, o: i + 10 }
    54  		out: a10.o
    55  	}
    56  	k00: 0
    57  	k10: (#add10 & {in: k00}).out
    58  	k20: (#add10 & {in: k10}).out
    59  	k30: (#add10 & {in: k20}).out
    60  }
    61  -- issue3182.cue --
    62  issue3182: {
    63  	first: t1: {
    64  		x: { a: x }.a
    65  	}
    66  	first: t2: {
    67  		x: { a: b: x }.a
    68  	}
    69  	second: {
    70  		{ t: x }.t.y
    71  		x: y: x: y: a: 1
    72  	}
    73  	third: {
    74  		{
    75  			p: {
    76  			  x: p
    77  			  y: 1
    78  			}
    79  		}.p.x.y
    80  	}
    81  }
    82  -- select.cue --
    83  // The value of #Step should be consistent between these test cases.
    84  select: direct: {
    85  	#Step: (#Job & {opt: _}).opt
    86  	#Job: matchN(1, [#NormalJob])
    87  }
    88  select: indirect: {
    89  	#Step: #Job.opt
    90  	#Job: matchN(1, [#NormalJob]) & {opt: _}
    91  }
    92  #NormalJob: {
    93  	req!: int
    94  	opt?: run?: string
    95  }
    96  -- out/evalalpha/stats --
    97  Leaks:  225
    98  Freed:  0
    99  Reused: 0
   100  Allocs: 225
   101  Retain: 0
   102  
   103  Unifications: 141
   104  Conjuncts:    375
   105  Disjuncts:    0
   106  
   107  CloseIDElems: 14
   108  NumCloseIDs: 178
   109  -- out/evalalpha --
   110  Errors:
   111  issue3182.first.t2.x.b: structural cycle
   112  
   113  Result:
   114  (_|_){
   115    // [structural cycle]
   116    ok1: (struct){
   117      f: (struct){
   118        in: (number){ number }
   119        out: (number){ number }
   120      }
   121      k00: (int){ 0 }
   122      k10: (int){ 0 }
   123      k20: (int){ 0 }
   124      k30: (int){ 0 }
   125    }
   126    ok2: (struct){
   127      f: (struct){
   128        in: (number){ number }
   129        out: (number){ number }
   130      }
   131      k00: (int){ 0 }
   132      k10: (int){ 0 }
   133      k20: (int){ 0 }
   134      k30: (int){ 0 }
   135    }
   136    ok3: (struct){
   137      f: (struct){
   138        in: (number){ number }
   139        out: (number){ number }
   140      }
   141      k00: (int){ 0 }
   142      k10: (int){ 0 }
   143      k20: (int){ 0 }
   144      k30: (int){ 0 }
   145    }
   146    ok4: (struct){
   147      f: (struct){
   148        in: (number){ number }
   149        out: (number){ number }
   150      }
   151      k00: (int){ 0 }
   152      k10: (int){ 0 }
   153      k20: (int){ 0 }
   154      k30: (int){ 0 }
   155    }
   156    issue1708: (struct){
   157      #add10: (#struct){
   158        in: (number){ number }
   159        a10: (#struct){
   160          i: (number){ number }
   161          o: (_|_){
   162            // [incomplete] issue1708.#add10.a10.o: non-concrete value number in operand to +:
   163            //     ./in.cue:52:20
   164            //     ./in.cue:51:7
   165          }
   166        }
   167        out: (_|_){
   168          // [incomplete] issue1708.#add10.a10.o: non-concrete value number in operand to +:
   169          //     ./in.cue:52:20
   170          //     ./in.cue:51:7
   171        }
   172      }
   173      k00: (int){ 0 }
   174      k10: (int){ 10 }
   175      k20: (int){ 20 }
   176      k30: (_|_){
   177        // [incomplete] a10.i: undefined field: out:
   178        //     ./in.cue:56:28
   179      }
   180    }
   181    issue3182: (_|_){
   182      // [structural cycle]
   183      first: (_|_){
   184        // [structural cycle]
   185        t1: (struct){
   186          x: (_){ _ }
   187        }
   188        t2: (_|_){
   189          // [structural cycle]
   190          x: (_|_){
   191            // [structural cycle]
   192            b: (_|_){
   193              // [structural cycle] issue3182.first.t2.x.b: structural cycle
   194            }
   195          }
   196        }
   197      }
   198      second: (struct){
   199        x: (struct){
   200          y: (struct){
   201            x: (struct){
   202              y: (struct){
   203                a: (int){ 1 }
   204              }
   205            }
   206            a: (int){ 1 }
   207          }
   208        }
   209        a: (int){ 1 }
   210      }
   211      third: (int){ 1 }
   212    }
   213    select: (struct){
   214      direct: (struct){
   215        #Step: (_){ _ }
   216        #Job: (_){ matchN(1, (#list){
   217            0: (_|_){// 〈3;#NormalJob〉
   218            }
   219          }) }
   220      }
   221      indirect: (struct){
   222        #Step: (_){ _ }
   223        #Job: (_|_){
   224          // [incomplete] select.indirect.#Job: invalid value {opt:_} (does not satisfy matchN): 0 matched, expected 1:
   225          //     ./select.cue:8:8
   226          //     ./select.cue:8:15
   227          // select.indirect.#Job.req: field is required but not present:
   228          //     ./select.cue:8:8
   229          //     ./select.cue:11:2
   230          opt: (_){ _ }
   231        }
   232      }
   233    }
   234    #NormalJob: (#struct){
   235      req!: (int){ int }
   236      opt?: (#struct){
   237        run?: (string){ string }
   238      }
   239    }
   240  }
   241  -- diff/-out/evalalpha/stats<==>+out/eval/stats --
   242  diff old new
   243  --- old
   244  +++ new
   245  @@ -1,9 +1,12 @@
   246  -Leaks:  309
   247  -Freed:  437
   248  -Reused: 429
   249  -Allocs: 317
   250  -Retain: 1074
   251  -
   252  -Unifications: 746
   253  -Conjuncts:    2813
   254  -Disjuncts:    1485
   255  +Leaks:  225
   256  +Freed:  0
   257  +Reused: 0
   258  +Allocs: 225
   259  +Retain: 0
   260  +
   261  +Unifications: 141
   262  +Conjuncts:    375
   263  +Disjuncts:    0
   264  +
   265  +CloseIDElems: 14
   266  +NumCloseIDs: 178
   267  -- diff/-out/evalalpha<==>+out/eval --
   268  diff old new
   269  --- old
   270  +++ new
   271  @@ -53,20 +53,21 @@
   272             // [incomplete] issue1708.#add10.a10.o: non-concrete value number in operand to +:
   273             //     ./in.cue:52:20
   274             //     ./in.cue:51:7
   275  -          //     ./in.cue:52:13
   276           }
   277         }
   278         out: (_|_){
   279  -        // [incomplete] issue1708.#add10.out: non-concrete value number in operand to +:
   280  +        // [incomplete] issue1708.#add10.a10.o: non-concrete value number in operand to +:
   281           //     ./in.cue:52:20
   282           //     ./in.cue:51:7
   283  -        //     ./in.cue:52:13
   284         }
   285       }
   286       k00: (int){ 0 }
   287       k10: (int){ 10 }
   288       k20: (int){ 20 }
   289  -    k30: (int){ 30 }
   290  +    k30: (_|_){
   291  +      // [incomplete] a10.i: undefined field: out:
   292  +      //     ./in.cue:56:28
   293  +    }
   294     }
   295     issue3182: (_|_){
   296       // [structural cycle]
   297  @@ -116,7 +117,6 @@
   298           //     ./select.cue:8:15
   299           // select.indirect.#Job.req: field is required but not present:
   300           //     ./select.cue:8:8
   301  -        //     ./select.cue:8:19
   302           //     ./select.cue:11:2
   303           opt: (_){ _ }
   304         }
   305  -- diff/todo/p2 --
   306  issue1708.k30: no longer evaluates. Not the worst, but would ideally be fixed.
   307  -- diff/todo/p3 --
   308  Error positions.
   309  Incorrect path due to structure sharing.
   310  -- out/eval/stats --
   311  Leaks:  309
   312  Freed:  437
   313  Reused: 429
   314  Allocs: 317
   315  Retain: 1074
   316  
   317  Unifications: 746
   318  Conjuncts:    2813
   319  Disjuncts:    1485
   320  -- out/eval --
   321  Errors:
   322  issue3182.first.t2.x.b: structural cycle
   323  
   324  Result:
   325  (_|_){
   326    // [structural cycle]
   327    ok1: (struct){
   328      f: (struct){
   329        in: (number){ number }
   330        out: (number){ number }
   331      }
   332      k00: (int){ 0 }
   333      k10: (int){ 0 }
   334      k20: (int){ 0 }
   335      k30: (int){ 0 }
   336    }
   337    ok2: (struct){
   338      f: (struct){
   339        in: (number){ number }
   340        out: (number){ number }
   341      }
   342      k00: (int){ 0 }
   343      k10: (int){ 0 }
   344      k20: (int){ 0 }
   345      k30: (int){ 0 }
   346    }
   347    ok3: (struct){
   348      f: (struct){
   349        in: (number){ number }
   350        out: (number){ number }
   351      }
   352      k00: (int){ 0 }
   353      k10: (int){ 0 }
   354      k20: (int){ 0 }
   355      k30: (int){ 0 }
   356    }
   357    ok4: (struct){
   358      f: (struct){
   359        in: (number){ number }
   360        out: (number){ number }
   361      }
   362      k00: (int){ 0 }
   363      k10: (int){ 0 }
   364      k20: (int){ 0 }
   365      k30: (int){ 0 }
   366    }
   367    issue1708: (struct){
   368      #add10: (#struct){
   369        in: (number){ number }
   370        a10: (#struct){
   371          i: (number){ number }
   372          o: (_|_){
   373            // [incomplete] issue1708.#add10.a10.o: non-concrete value number in operand to +:
   374            //     ./in.cue:52:20
   375            //     ./in.cue:51:7
   376            //     ./in.cue:52:13
   377          }
   378        }
   379        out: (_|_){
   380          // [incomplete] issue1708.#add10.out: non-concrete value number in operand to +:
   381          //     ./in.cue:52:20
   382          //     ./in.cue:51:7
   383          //     ./in.cue:52:13
   384        }
   385      }
   386      k00: (int){ 0 }
   387      k10: (int){ 10 }
   388      k20: (int){ 20 }
   389      k30: (int){ 30 }
   390    }
   391    issue3182: (_|_){
   392      // [structural cycle]
   393      first: (_|_){
   394        // [structural cycle]
   395        t1: (struct){
   396          x: (_){ _ }
   397        }
   398        t2: (_|_){
   399          // [structural cycle]
   400          x: (_|_){
   401            // [structural cycle]
   402            b: (_|_){
   403              // [structural cycle] issue3182.first.t2.x.b: structural cycle
   404            }
   405          }
   406        }
   407      }
   408      second: (struct){
   409        x: (struct){
   410          y: (struct){
   411            x: (struct){
   412              y: (struct){
   413                a: (int){ 1 }
   414              }
   415            }
   416            a: (int){ 1 }
   417          }
   418        }
   419        a: (int){ 1 }
   420      }
   421      third: (int){ 1 }
   422    }
   423    select: (struct){
   424      direct: (struct){
   425        #Step: (_){ _ }
   426        #Job: (_){ matchN(1, (#list){
   427            0: (_|_){// 〈3;#NormalJob〉
   428            }
   429          }) }
   430      }
   431      indirect: (struct){
   432        #Step: (_){ _ }
   433        #Job: (_|_){
   434          // [incomplete] select.indirect.#Job: invalid value {opt:_} (does not satisfy matchN): 0 matched, expected 1:
   435          //     ./select.cue:8:8
   436          //     ./select.cue:8:15
   437          // select.indirect.#Job.req: field is required but not present:
   438          //     ./select.cue:8:8
   439          //     ./select.cue:8:19
   440          //     ./select.cue:11:2
   441          opt: (_){ _ }
   442        }
   443      }
   444    }
   445    #NormalJob: (#struct){
   446      req!: (int){ int }
   447      opt?: (#struct){
   448        run?: (string){ string }
   449      }
   450    }
   451  }
   452  -- out/compile --
   453  --- in.cue
   454  {
   455    ok1: {
   456      f: {
   457        in: number
   458        out: 〈0;in〉
   459      }
   460      k00: 0
   461      k10: (〈0;f〉 & {
   462        in: 〈1;k00〉
   463      }).out
   464      k20: (〈0;f〉 & {
   465        in: 〈1;k10〉
   466      }).out
   467      k30: (〈0;f〉 & {
   468        in: 〈1;k20〉
   469      }).out
   470    }
   471    ok2: {
   472      f: {
   473        in: number
   474        out: 〈0;in〉
   475      }
   476      k00: 0
   477      k10: {
   478        (〈1;f〉 & {
   479          in: 〈2;k00〉
   480        }).out
   481      }
   482      k20: {
   483        (〈1;f〉 & {
   484          in: 〈2;k10〉
   485        }).out
   486      }
   487      k30: {
   488        (〈1;f〉 & {
   489          in: 〈2;k20〉
   490        }).out
   491      }
   492    }
   493    ok3: {
   494      f: {
   495        in: number
   496        out: 〈0;in〉
   497      }
   498      k00: 0
   499      k10: {
   500        close((〈1;f〉 & {
   501          in: 〈2;k00〉
   502        })).out
   503      }
   504      k20: {
   505        close((〈1;f〉 & {
   506          in: 〈2;k10〉
   507        })).out
   508      }
   509      k30: {
   510        close((〈1;f〉 & {
   511          in: 〈2;k20〉
   512        })).out
   513      }
   514    }
   515    ok4: {
   516      f: {
   517        in: number
   518        out: 〈0;in〉
   519      }
   520      k00: 0
   521      k10: {
   522        out: {
   523          (〈2;f〉 & {
   524            in: 〈3;k00〉
   525          }).out
   526        }
   527      }.out
   528      k20: {
   529        out: {
   530          (〈2;f〉 & {
   531            in: 〈3;k10〉
   532          }).out
   533        }
   534      }.out
   535      k30: {
   536        out: {
   537          (〈2;f〉 & {
   538            in: 〈3;k20〉
   539          }).out
   540        }
   541      }.out
   542    }
   543    issue1708: {
   544      #add10: {
   545        in: number
   546        a10: {
   547          i: 〈1;in〉
   548          o: (〈0;i〉 + 10)
   549        }
   550        out: 〈0;a10〉.o
   551      }
   552      k00: 0
   553      k10: (〈0;#add10〉 & {
   554        in: 〈1;k00〉
   555      }).out
   556      k20: (〈0;#add10〉 & {
   557        in: 〈1;k10〉
   558      }).out
   559      k30: (〈0;#add10〉 & {
   560        in: 〈1;k20〉
   561      }).out
   562    }
   563  }
   564  --- issue3182.cue
   565  {
   566    issue3182: {
   567      first: {
   568        t1: {
   569          x: {
   570            a: 〈1;x〉
   571          }.a
   572        }
   573      }
   574      first: {
   575        t2: {
   576          x: {
   577            a: {
   578              b: 〈2;x〉
   579            }
   580          }.a
   581        }
   582      }
   583      second: {
   584        {
   585          t: 〈1;x〉
   586        }.t.y
   587        x: {
   588          y: {
   589            x: {
   590              y: {
   591                a: 1
   592              }
   593            }
   594          }
   595        }
   596      }
   597      third: {
   598        {
   599          p: {
   600            x: 〈1;p〉
   601            y: 1
   602          }
   603        }.p.x.y
   604      }
   605    }
   606  }
   607  --- select.cue
   608  {
   609    select: {
   610      direct: {
   611        #Step: (〈0;#Job〉 & {
   612          opt: _
   613        }).opt
   614        #Job: matchN(1, [
   615          〈3;#NormalJob〉,
   616        ])
   617      }
   618    }
   619    select: {
   620      indirect: {
   621        #Step: 〈0;#Job〉.opt
   622        #Job: (matchN(1, [
   623          〈3;#NormalJob〉,
   624        ]) & {
   625          opt: _
   626        })
   627      }
   628    }
   629    #NormalJob: {
   630      req!: int
   631      opt?: {
   632        run?: string
   633      }
   634    }
   635  }