...

Text file src/cuelang.org/go/cue/testdata/cycle/issue1960.txtar

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

     1// Issue-specific tests. Essence tested in evaluate.txtar (LetCycle*).
     2-- issue1960.cue --
     3t1: {
     4	z: blah: s: [for z in z {}]
     5	z: hello: {
     6		for x in p {}
     7		let q = z.blah
     8		p: q.r // Incomplete error should not cause cycle.
     9		p: t: 1
    10	}
    11}
    12
    13t2: {
    14	z: blah: s: [for z in z {}]
    15	z: hello: {
    16		for x in p {}
    17		let q = z.blah
    18		p: t: 1
    19	}
    20}
    21
    22t3: {
    23	#z: {
    24		n: string
    25		p: t: "e"
    26		s: [...string]
    27		_p: {
    28			n: string
    29			e: p: {}
    30		}
    31		r: (_p )[p.t]
    32		for _, pl in r.p {
    33			if pl.blah {
    34			}
    35		}
    36	}
    37
    38	#i: {
    39		#z
    40		t: "i"
    41		r: e: {}
    42	}
    43
    44	#c: {
    45		#z
    46		t: "c"
    47		n: string
    48	}
    49
    50	z: [N= =~"^b"]: #i & {
    51		s: [
    52			for n, z in z
    53			if z.t == "c"
    54			if z.n == N {n},
    55		]
    56	}
    57
    58	z: [N= =~"^h"]: #c & {
    59		n: string
    60		// Causes a structural cycle on its own, but not when referenced below.
    61		let q = z[n]
    62		p: q.r.e
    63	}
    64
    65	z: {
    66		"blah": {}
    67		"hello": n: "blah"
    68	}
    69}
    70-- out/eval --
    71t2.z.hello: unreferenced alias or let clause q:
    72    ./issue1960.cue:15:3
    73-- out/compile --
    74t2.z.hello: unreferenced alias or let clause q:
    75    ./issue1960.cue:15:3
    76--- issue1960.cue
    77{
    78  t1: {
    79    z: {
    80      blah: {
    81        s: [
    82          for _, z in 〈3;z〉 {},
    83        ]
    84      }
    85    }
    86    z: {
    87      hello: {
    88        for _, x in 〈0;p〉 {}
    89        let q#1 = 〈2;z〉.blah
    90        p: 〈0;let q#1〉.r
    91        p: {
    92          t: 1
    93        }
    94      }
    95    }
    96  }
    97  t2: {
    98    z: {
    99      blah: {
   100        s: [
   101          for _, z in 〈3;z〉 {},
   102        ]
   103      }
   104    }
   105    z: {
   106      hello: {
   107        for _, x in 〈0;p〉 {}
   108        let q#2 = 〈2;z〉.blah
   109        p: {
   110          t: 1
   111        }
   112      }
   113    }
   114  }
   115  t3: {
   116    #z: {
   117      n: string
   118      p: {
   119        t: "e"
   120      }
   121      s: [
   122        ...string,
   123      ]
   124      _p: {
   125        n: string
   126        e: {
   127          p: {}
   128        }
   129      }
   130      r: 〈0;_p〉[〈0;p〉.t]
   131      for _, pl in 〈0;r〉.p {
   132        if 〈1;pl〉.blah {}
   133      }
   134    }
   135    #i: {
   136      〈1;#z〉
   137      t: "i"
   138      r: {
   139        e: {}
   140      }
   141    }
   142    #c: {
   143      〈1;#z〉
   144      t: "c"
   145      n: string
   146    }
   147    z: {
   148      [=~"^b"]: (〈1;#i〉 & {
   149        s: [
   150          for n, z in 〈3;z〉 if (〈0;z〉.t == "c") if (〈0;z〉.n == 〈3;-〉) {
   151            〈1;n〉
   152          },
   153        ]
   154      })
   155    }
   156    z: {
   157      [=~"^h"]: (〈1;#c〉 & {
   158        n: string
   159        let q#3 = 〈2;z〉[〈0;n〉]
   160        p: 〈0;let q#3〉.r.e
   161      })
   162    }
   163    z: {
   164      blah: {}
   165      hello: {
   166        n: "blah"
   167      }
   168    }
   169  }
   170}

View as plain text