cuelang.org/go@v0.13.0/cue/testdata/fulleval/049_alias_reuse_in_nested_scope.txtar (about)

     1  #name: alias reuse in nested scope
     2  #evalFull
     3  -- in.cue --
     4  #Foo: {
     5  	let X = or([for k, _ in {} {k}])
     6  	connection: [X]: X
     7  }
     8  #A: {
     9  	foo: "key"
    10  	let X = foo
    11  	a: foo: [X]: X
    12  }
    13  #B: {
    14  	foo: string
    15  	let X = foo
    16  	a: foo: [X]: X
    17  }
    18  b: #B & {foo: "key"}
    19  -- out/def --
    20  #Foo: {
    21  	connection: {
    22  		[or([for k, _ in {
    23  				...
    24  		} { k }])]: or([for k, _ in {
    25  			...
    26  		} { k }])
    27  	}
    28  }
    29  #A: {
    30  	foo: "key"
    31  	a: {
    32  		foo: {
    33  			["key"]: "key"
    34  		}
    35  	}
    36  }
    37  #B: {
    38  	foo: string
    39  	FOO = foo
    40  	a: {
    41  		foo: {
    42  			[FOO]: FOO
    43  		}
    44  	}
    45  }
    46  b: #B & {
    47  	foo: "key"
    48  }
    49  -- out/export --
    50  b: {
    51  	foo: "key"
    52  	a: {
    53  		foo: {}
    54  	}
    55  }
    56  -- out/yaml --
    57  b:
    58    foo: key
    59    a:
    60      foo: {}
    61  -- out/json --
    62  {"b":{"foo":"key","a":{"foo":{}}}}
    63  -- out/legacy-debug --
    64  <0>{#Foo: <1>C{connection: <2>C{[or ([ <3>for k, _ in <4>{} yield <3>.k ])]: <5>(_: string)->or ([ <3>for k, _ in <4>{} yield <3>.k ]), }}, #A: <6>C{foo: "key", a: <7>C{foo: <8>C{["key"]: <9>(_: string)-><10>.foo, }}}, #B: <11>C{foo: string, a: <12>C{foo: <13>C{[string]: <14>(_: string)-><15>.foo, }}}, b: <16>C{foo: "key", a: <17>C{foo: <18>C{["key"]: <19>(_: string)-><20>.foo, }}}}
    65  -- out/eval/stats --
    66  Leaks:  10
    67  Freed:  19
    68  Reused: 15
    69  Allocs: 14
    70  Retain: 10
    71  
    72  Unifications: 29
    73  Conjuncts:    40
    74  Disjuncts:    29
    75  -- out/evalalpha --
    76  (struct){
    77    #Foo: (#struct){
    78      let X#1 = (_|_){
    79        // [incomplete] empty list in call to or:
    80        //     ./in.cue:2:10
    81      }
    82      connection: (_|_){
    83        // [incomplete] empty list in call to or:
    84        //     ./in.cue:2:10
    85      }
    86    }
    87    #A: (#struct){
    88      foo: (string){ "key" }
    89      let X#2 = (string){ "key" }
    90      a: (#struct){
    91        foo: (#struct){
    92        }
    93      }
    94    }
    95    #B: (#struct){
    96      foo: (string){ string }
    97      let X#3 = (string){ string }
    98      a: (#struct){
    99        foo: (#struct){
   100        }
   101      }
   102    }
   103    b: (#struct){
   104      foo: (string){ "key" }
   105      let X#3 = (string){ "key" }
   106      a: (#struct){
   107        foo: (#struct){
   108        }
   109      }
   110    }
   111  }
   112  -- diff/-out/evalalpha<==>+out/eval --
   113  diff old new
   114  --- old
   115  +++ new
   116  @@ -4,7 +4,9 @@
   117         // [incomplete] empty list in call to or:
   118         //     ./in.cue:2:10
   119       }
   120  -    connection: (#struct){
   121  +    connection: (_|_){
   122  +      // [incomplete] empty list in call to or:
   123  +      //     ./in.cue:2:10
   124       }
   125     }
   126     #A: (#struct){
   127  -- diff/explanation --
   128  The new error is a correct error, as the pattern constraint is invalid.
   129  Seems reasonable to report error at connection as well.
   130  -- out/eval --
   131  (struct){
   132    #Foo: (#struct){
   133      let X#1 = (_|_){
   134        // [incomplete] empty list in call to or:
   135        //     ./in.cue:2:10
   136      }
   137      connection: (#struct){
   138      }
   139    }
   140    #A: (#struct){
   141      foo: (string){ "key" }
   142      let X#2 = (string){ "key" }
   143      a: (#struct){
   144        foo: (#struct){
   145        }
   146      }
   147    }
   148    #B: (#struct){
   149      foo: (string){ string }
   150      let X#3 = (string){ string }
   151      a: (#struct){
   152        foo: (#struct){
   153        }
   154      }
   155    }
   156    b: (#struct){
   157      foo: (string){ "key" }
   158      let X#3 = (string){ "key" }
   159      a: (#struct){
   160        foo: (#struct){
   161        }
   162      }
   163    }
   164  }
   165  -- out/compile --
   166  --- in.cue
   167  {
   168    #Foo: {
   169      let X#1 = or([
   170        for k, _ in {} {
   171          〈1;k〉
   172        },
   173      ])
   174      connection: {
   175        [〈1;let X#1〉]: 〈1;let X#1〉
   176      }
   177    }
   178    #A: {
   179      foo: "key"
   180      let X#2 = 〈0;foo〉
   181      a: {
   182        foo: {
   183          [〈2;let X#2〉]: 〈2;let X#2〉
   184        }
   185      }
   186    }
   187    #B: {
   188      foo: string
   189      let X#3 = 〈0;foo〉
   190      a: {
   191        foo: {
   192          [〈2;let X#3〉]: 〈2;let X#3〉
   193        }
   194      }
   195    }
   196    b: (〈0;#B〉 & {
   197      foo: "key"
   198    })
   199  }