...

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

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

     1-- in.cue --
     2// Test that an error in a let that is merged with itself from two different
     3// origins does not result in an error as long as the error is not referenced
     4// outside the let.
     5t1: {
     6	x: {
     7		a: int
     8		y: {
     9			let X = {
    10				b: a
    11				c: 1
    12			}
    13			v: X.c
    14		}
    15	}
    16
    17	x1: x
    18	x1: a: 1
    19
    20	x2: x
    21	x2: a: 2
    22
    23	xy: x1.y & x2.y
    24}
    25
    26t2: {
    27	x: {
    28		a: {}
    29		y: {
    30			let X = {
    31				b: a
    32				c: 1
    33			}
    34			v: X.c
    35		}
    36	}
    37
    38	x1: x
    39	x1: a: q: 1
    40
    41	x2: x
    42	x2: a: r: 2
    43
    44	xy: x1 & x2
    45}
    46-- out/eval/stats --
    47Leaks:  8
    48Freed:  65
    49Reused: 60
    50Allocs: 13
    51Retain: 8
    52
    53Unifications: 73
    54Conjuncts:    123
    55Disjuncts:    69
    56-- out/evalalpha --
    57(struct){
    58  t1: (struct){
    59    x: (struct){
    60      a: (int){ int }
    61      y: (struct){
    62        let X#1 = (struct){
    63          b: (int){ int }
    64          c: (int){ 1 }
    65        }
    66        v: (int){ 1 }
    67      }
    68    }
    69    x1: (struct){
    70      a: (int){ 1 }
    71      y: (struct){
    72        let X#1 = (struct){
    73          b: (int){ 1 }
    74          c: (int){ 1 }
    75        }
    76        v: (int){ 1 }
    77      }
    78    }
    79    x2: (struct){
    80      a: (int){ 2 }
    81      y: (struct){
    82        let X#1 = (struct){
    83          b: (int){ 2 }
    84          c: (int){ 1 }
    85        }
    86        v: (int){ 1 }
    87      }
    88    }
    89    xy: (struct){
    90      let X#1multi = &[&[&[{
    91        b: 〈2;a〉
    92        c: 1
    93      }]]]
    94      v: (int){ 1 }
    95    }
    96  }
    97  t2: (struct){
    98    x: (struct){
    99      a: (struct){
   100      }
   101      y: (struct){
   102        let X#2 = (struct){
   103          b: (struct){
   104          }
   105          c: (int){ 1 }
   106        }
   107        v: (int){ 1 }
   108      }
   109    }
   110    x1: (struct){
   111      a: (struct){
   112        q: (int){ 1 }
   113      }
   114      y: (struct){
   115        let X#2 = (struct){
   116          b: (struct){
   117            q: (int){ 1 }
   118          }
   119          c: (int){ 1 }
   120        }
   121        v: (int){ 1 }
   122      }
   123    }
   124    x2: (struct){
   125      a: (struct){
   126        r: (int){ 2 }
   127      }
   128      y: (struct){
   129        let X#2 = (struct){
   130          b: (struct){
   131            r: (int){ 2 }
   132          }
   133          c: (int){ 1 }
   134        }
   135        v: (int){ 1 }
   136      }
   137    }
   138    xy: (struct){
   139      a: (struct){
   140        q: (int){ 1 }
   141        r: (int){ 2 }
   142      }
   143      y: (struct){
   144        let X#2 = (struct){
   145          b: (struct){
   146            q: (int){ 1 }
   147            r: (int){ 2 }
   148          }
   149          c: (int){ 1 }
   150        }
   151        v: (int){ 1 }
   152      }
   153    }
   154  }
   155}
   156-- diff/-out/evalalpha<==>+out/eval --
   157diff old new
   158--- old
   159+++ new
   160@@ -31,10 +31,10 @@
   161       }
   162     }
   163     xy: (struct){
   164-      let X#1multi = {
   165+      let X#1multi = &[&[&[{
   166         b: 〈2;a〉
   167         c: 1
   168-      }
   169+      }]]]
   170       v: (int){ 1 }
   171     }
   172   }
   173@@ -85,9 +85,12 @@
   174         r: (int){ 2 }
   175       }
   176       y: (struct){
   177-        let X#2multi = {
   178-          b: 〈2;a〉
   179-          c: 1
   180+        let X#2 = (struct){
   181+          b: (struct){
   182+            q: (int){ 1 }
   183+            r: (int){ 2 }
   184+          }
   185+          c: (int){ 1 }
   186         }
   187         v: (int){ 1 }
   188       }
   189-- diff/todo/p4 --
   190Reduce conjunct group size. Semantically correct, though.
   191-- out/eval --
   192(struct){
   193  t1: (struct){
   194    x: (struct){
   195      a: (int){ int }
   196      y: (struct){
   197        let X#1 = (struct){
   198          b: (int){ int }
   199          c: (int){ 1 }
   200        }
   201        v: (int){ 1 }
   202      }
   203    }
   204    x1: (struct){
   205      a: (int){ 1 }
   206      y: (struct){
   207        let X#1 = (struct){
   208          b: (int){ 1 }
   209          c: (int){ 1 }
   210        }
   211        v: (int){ 1 }
   212      }
   213    }
   214    x2: (struct){
   215      a: (int){ 2 }
   216      y: (struct){
   217        let X#1 = (struct){
   218          b: (int){ 2 }
   219          c: (int){ 1 }
   220        }
   221        v: (int){ 1 }
   222      }
   223    }
   224    xy: (struct){
   225      let X#1multi = {
   226        b: 〈2;a〉
   227        c: 1
   228      }
   229      v: (int){ 1 }
   230    }
   231  }
   232  t2: (struct){
   233    x: (struct){
   234      a: (struct){
   235      }
   236      y: (struct){
   237        let X#2 = (struct){
   238          b: (struct){
   239          }
   240          c: (int){ 1 }
   241        }
   242        v: (int){ 1 }
   243      }
   244    }
   245    x1: (struct){
   246      a: (struct){
   247        q: (int){ 1 }
   248      }
   249      y: (struct){
   250        let X#2 = (struct){
   251          b: (struct){
   252            q: (int){ 1 }
   253          }
   254          c: (int){ 1 }
   255        }
   256        v: (int){ 1 }
   257      }
   258    }
   259    x2: (struct){
   260      a: (struct){
   261        r: (int){ 2 }
   262      }
   263      y: (struct){
   264        let X#2 = (struct){
   265          b: (struct){
   266            r: (int){ 2 }
   267          }
   268          c: (int){ 1 }
   269        }
   270        v: (int){ 1 }
   271      }
   272    }
   273    xy: (struct){
   274      a: (struct){
   275        q: (int){ 1 }
   276        r: (int){ 2 }
   277      }
   278      y: (struct){
   279        let X#2multi = {
   280          b: 〈2;a〉
   281          c: 1
   282        }
   283        v: (int){ 1 }
   284      }
   285    }
   286  }
   287}
   288-- out/compile --
   289--- in.cue
   290{
   291  t1: {
   292    x: {
   293      a: int
   294      y: {
   295        let X#1 = {
   296          b: 〈2;a〉
   297          c: 1
   298        }
   299        v: 〈0;let X#1〉.c
   300      }
   301    }
   302    x1: 〈0;x〉
   303    x1: {
   304      a: 1
   305    }
   306    x2: 〈0;x〉
   307    x2: {
   308      a: 2
   309    }
   310    xy: (〈0;x1〉.y & 〈0;x2〉.y)
   311  }
   312  t2: {
   313    x: {
   314      a: {}
   315      y: {
   316        let X#2 = {
   317          b: 〈2;a〉
   318          c: 1
   319        }
   320        v: 〈0;let X#2〉.c
   321      }
   322    }
   323    x1: 〈0;x〉
   324    x1: {
   325      a: {
   326        q: 1
   327      }
   328    }
   329    x2: 〈0;x〉
   330    x2: {
   331      a: {
   332        r: 2
   333      }
   334    }
   335    xy: (〈0;x1〉 & 〈0;x2〉)
   336  }
   337}

View as plain text