...

Text file src/cuelang.org/go/cue/testdata/eval/bulk.txtar

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

     1-- in.cue --
     2a: {
     3	foo: a: 1
     4	[X = =~"foo"]: {
     5		b:    1
     6		name: X
     7	}
     8}
     9d: a & {
    10	"foobar": {
    11		c: 2
    12	}
    13}
    14
    15t1: {
    16	#a: {
    17		[>"e" & <"z"]: int
    18	}
    19	b: #a & {f: 4}
    20	c: #a & {z: 4}
    21}
    22
    23t2: {
    24	#a: {
    25		["x" | "y"]: int
    26	}
    27	b: #a & {x: 4}
    28	c: #a & {z: 4}
    29}
    30
    31-- issue2109.cue --
    32// Detect cycle:
    33// The pattern constraint of FlagsURLS is applied to countries (because
    34// FlagsURLs  is embedded. But the pattern constraint itself refers to
    35// countries. So countries -> or(countries) -> countries.
    36//
    37// Theoretically, or(countries) can be resolved without a cycle. And then we
    38// could see it does not apply to countries. For now we stick with this
    39// approach understanding that it is easier to relax later.
    40patternCycle: issue2109: p1: {
    41	countries: ["US", "GB", "AU"]
    42	FlagsURLs: {[or(countries)]: string}
    43	FlagsURLs
    44}
    45patternCycle: issue2109: p2: {
    46	FlagsURLs: {[or(countries)]: string}
    47	FlagsURLs
    48	countries: ["US", "GB", "AU"]
    49}
    50patternCycle: issue2109: p3: {
    51	FlagsURLs
    52	FlagsURLs: {[or(countries)]: string}
    53	countries: ["US", "GB", "AU"]
    54}
    55
    56patternCycle: t1: p1: {
    57	countries: "US" | "GB" | "AU"
    58	FlagsURLs: {[countries]: string}
    59	FlagsURLs
    60}
    61patternCycle: t1: p2: {
    62	FlagsURLs
    63	countries: "US" | "GB" | "AU"
    64	FlagsURLs: {[countries]: string}
    65}
    66patternCycle: t1: p3: {
    67	FlagsURLs
    68	FlagsURLs: {[countries]: string}
    69	countries: "US" | "GB" | "AU"
    70}
    71
    72-- out/eval/stats --
    73Leaks:  4
    74Freed:  80
    75Reused: 73
    76Allocs: 11
    77Retain: 12
    78
    79Unifications: 63
    80Conjuncts:    126
    81Disjuncts:    90
    82-- out/eval --
    83Errors:
    84t1.c.z: field not allowed:
    85    ./in.cue:15:6
    86    ./in.cue:19:5
    87    ./in.cue:19:11
    88t2.c.z: field not allowed:
    89    ./in.cue:23:6
    90    ./in.cue:27:5
    91    ./in.cue:27:11
    92patternCycle.issue2109.p1.countries: cyclic pattern constraint:
    93    ./issue2109.cue:11:15
    94    ./issue2109.cue:10:13
    95patternCycle.issue2109.p2.countries: cyclic pattern constraint:
    96    ./issue2109.cue:15:15
    97    ./issue2109.cue:17:13
    98patternCycle.issue2109.p3.countries: cyclic pattern constraint:
    99    ./issue2109.cue:21:15
   100    ./issue2109.cue:22:13
   101patternCycle.t1.p1.countries: cyclic pattern constraint:
   102    ./issue2109.cue:27:15
   103    ./issue2109.cue:26:13
   104patternCycle.t1.p2.countries: cyclic pattern constraint:
   105    ./issue2109.cue:33:15
   106    ./issue2109.cue:32:13
   107patternCycle.t1.p3.countries: cyclic pattern constraint:
   108    ./issue2109.cue:37:15
   109    ./issue2109.cue:38:13
   110
   111Result:
   112(_|_){
   113  // [eval]
   114  a: (struct){
   115    foo: (struct){
   116      a: (int){ 1 }
   117      b: (int){ 1 }
   118      name: (string){ "foo" }
   119    }
   120  }
   121  d: (struct){
   122    foo: (struct){
   123      a: (int){ 1 }
   124      b: (int){ 1 }
   125      name: (string){ "foo" }
   126    }
   127    foobar: (struct){
   128      c: (int){ 2 }
   129      b: (int){ 1 }
   130      name: (string){ "foobar" }
   131    }
   132  }
   133  t1: (_|_){
   134    // [eval]
   135    #a: (#struct){
   136    }
   137    b: (#struct){
   138      f: (int){ 4 }
   139    }
   140    c: (_|_){
   141      // [eval]
   142      z: (_|_){
   143        // [eval] t1.c.z: field not allowed:
   144        //     ./in.cue:15:6
   145        //     ./in.cue:19:5
   146        //     ./in.cue:19:11
   147      }
   148    }
   149  }
   150  t2: (_|_){
   151    // [eval]
   152    #a: (#struct){
   153    }
   154    b: (#struct){
   155      x: (int){ 4 }
   156    }
   157    c: (_|_){
   158      // [eval]
   159      z: (_|_){
   160        // [eval] t2.c.z: field not allowed:
   161        //     ./in.cue:23:6
   162        //     ./in.cue:27:5
   163        //     ./in.cue:27:11
   164      }
   165    }
   166  }
   167  patternCycle: (_|_){
   168    // [eval]
   169    issue2109: (_|_){
   170      // [eval]
   171      p1: (_|_){
   172        // [eval]
   173        countries: (_|_){
   174          // [eval] patternCycle.issue2109.p1.countries: cyclic pattern constraint:
   175          //     ./issue2109.cue:11:15
   176          //     ./issue2109.cue:10:13
   177          0: (string){ "US" }
   178          1: (string){ "GB" }
   179          2: (string){ "AU" }
   180        }
   181        FlagsURLs: (struct){
   182        }
   183      }
   184      p2: (_|_){
   185        // [eval]
   186        FlagsURLs: (struct){
   187        }
   188        countries: (_|_){
   189          // [eval] patternCycle.issue2109.p2.countries: cyclic pattern constraint:
   190          //     ./issue2109.cue:15:15
   191          //     ./issue2109.cue:17:13
   192          0: (_|_){// "US"
   193          }
   194          1: (_|_){// "GB"
   195          }
   196          2: (_|_){// "AU"
   197          }
   198        }
   199      }
   200      p3: (_|_){
   201        // [eval]
   202        FlagsURLs: (struct){
   203        }
   204        countries: (_|_){
   205          // [eval] patternCycle.issue2109.p3.countries: cyclic pattern constraint:
   206          //     ./issue2109.cue:21:15
   207          //     ./issue2109.cue:22:13
   208          0: (_|_){// "US"
   209          }
   210          1: (_|_){// "GB"
   211          }
   212          2: (_|_){// "AU"
   213          }
   214        }
   215      }
   216    }
   217    t1: (_|_){
   218      // [eval]
   219      p1: (_|_){
   220        // [eval]
   221        countries: (_|_){
   222          // [eval] patternCycle.t1.p1.countries: cyclic pattern constraint:
   223          //     ./issue2109.cue:27:15
   224          //     ./issue2109.cue:26:13
   225        }
   226        FlagsURLs: (struct){
   227        }
   228      }
   229      p2: (_|_){
   230        // [eval]
   231        countries: (_|_){
   232          // [eval] patternCycle.t1.p2.countries: cyclic pattern constraint:
   233          //     ./issue2109.cue:33:15
   234          //     ./issue2109.cue:32:13
   235        }
   236        FlagsURLs: (struct){
   237        }
   238      }
   239      p3: (_|_){
   240        // [eval]
   241        FlagsURLs: (struct){
   242        }
   243        countries: (_|_){
   244          // [eval] patternCycle.t1.p3.countries: cyclic pattern constraint:
   245          //     ./issue2109.cue:37:15
   246          //     ./issue2109.cue:38:13
   247        }
   248      }
   249    }
   250  }
   251}
   252-- out/compile --
   253--- in.cue
   254{
   255  a: {
   256    foo: {
   257      a: 1
   258    }
   259    [=~"foo"]: {
   260      b: 1
   261      name: 〈1;-〉
   262    }
   263  }
   264  d: (〈0;a〉 & {
   265    foobar: {
   266      c: 2
   267    }
   268  })
   269  t1: {
   270    #a: {
   271      [(>"e" & <"z")]: int
   272    }
   273    b: (〈0;#a〉 & {
   274      f: 4
   275    })
   276    c: (〈0;#a〉 & {
   277      z: 4
   278    })
   279  }
   280  t2: {
   281    #a: {
   282      [("x"|"y")]: int
   283    }
   284    b: (〈0;#a〉 & {
   285      x: 4
   286    })
   287    c: (〈0;#a〉 & {
   288      z: 4
   289    })
   290  }
   291}
   292--- issue2109.cue
   293{
   294  patternCycle: {
   295    issue2109: {
   296      p1: {
   297        countries: [
   298          "US",
   299          "GB",
   300          "AU",
   301        ]
   302        FlagsURLs: {
   303          [or(〈1;countries〉)]: string
   304        }
   305        〈0;FlagsURLs〉
   306      }
   307    }
   308  }
   309  patternCycle: {
   310    issue2109: {
   311      p2: {
   312        FlagsURLs: {
   313          [or(〈1;countries〉)]: string
   314        }
   315        〈0;FlagsURLs〉
   316        countries: [
   317          "US",
   318          "GB",
   319          "AU",
   320        ]
   321      }
   322    }
   323  }
   324  patternCycle: {
   325    issue2109: {
   326      p3: {
   327        〈0;FlagsURLs〉
   328        FlagsURLs: {
   329          [or(〈1;countries〉)]: string
   330        }
   331        countries: [
   332          "US",
   333          "GB",
   334          "AU",
   335        ]
   336      }
   337    }
   338  }
   339  patternCycle: {
   340    t1: {
   341      p1: {
   342        countries: ("US"|"GB"|"AU")
   343        FlagsURLs: {
   344          [〈1;countries〉]: string
   345        }
   346        〈0;FlagsURLs〉
   347      }
   348    }
   349  }
   350  patternCycle: {
   351    t1: {
   352      p2: {
   353        〈0;FlagsURLs〉
   354        countries: ("US"|"GB"|"AU")
   355        FlagsURLs: {
   356          [〈1;countries〉]: string
   357        }
   358      }
   359    }
   360  }
   361  patternCycle: {
   362    t1: {
   363      p3: {
   364        〈0;FlagsURLs〉
   365        FlagsURLs: {
   366          [〈1;countries〉]: string
   367        }
   368        countries: ("US"|"GB"|"AU")
   369      }
   370    }
   371  }
   372}

View as plain text