# Tests various patterns of insertion of conjuncts. # See https://cuelang.org/issues/2169 -- a.cue -- embeddingDirect: t1: { #a: _ _ } & { #a: "s" #a } embeddingExpr: t1: { #a: _ _ } & { #a: "s" [ #a ][0] } unifiedDirect: { t1: { #a: _ _ } t1: { #a #a: _ } t1: { _ #a: "s" } } unifiedExpr: { t1: { #a: _ _ } t1: { [ #a ][0] #a: _ } t1: { #a: "s" _ } } // These two embeddings both add fields to each other's original source, which // then, in turn, needs to be added. cross: t1: { a: { b: {v: 1, a: w: 2} // from b.a: {x: 2, b: y: 5} } b: { a: {x: 2, b: y: 5} // from a.b: {v: 1, a: v: 2} } a b } -- complex.cue -- // Multiple levels of insertion recursive: t1: { e: {} c: d: e: f: 1 c.d c: d: // This part gets embedded within t1, which ends up adding new fields // to here, when then again need to be embedded in t1, which then // will add more fields to node e. c: d: e: g: 1 } recursive: t2: { c c: c: g: 1 } -- issue2169.cue -- embeddedFunctionalExpr: { #fn: { #in: _ _ } & { #in: "str" ({ #t: _ #t } & { #t: #in _ }) + "" } #fn } -- out/eval/stats -- Leaks: 8 Freed: 59 Reused: 54 Allocs: 13 Retain: 24 Unifications: 67 Conjuncts: 163 Disjuncts: 73 -- out/eval -- (struct){ embeddingDirect: (struct){ t1: (string){ "s" #a: (string){ "s" } } } embeddingExpr: (struct){ t1: (string){ "s" #a: (string){ "s" } } } unifiedDirect: (struct){ t1: (string){ "s" #a: (string){ "s" } } } unifiedExpr: (struct){ t1: (string){ "s" #a: (string){ "s" } } } cross: (struct){ t1: (struct){ a: (struct){ b: (struct){ v: (int){ 1 } a: (struct){ w: (int){ 2 } } y: (int){ 5 } } x: (int){ 2 } w: (int){ 2 } } b: (struct){ a: (struct){ x: (int){ 2 } b: (struct){ y: (int){ 5 } } w: (int){ 2 } } v: (int){ 1 } y: (int){ 5 } } x: (int){ 2 } y: (int){ 5 } v: (int){ 1 } w: (int){ 2 } } } recursive: (struct){ t1: (struct){ e: (struct){ f: (int){ 1 } g: (int){ 1 } } c: (struct){ d: (struct){ e: (struct){ f: (int){ 1 } g: (int){ 1 } } c: (struct){ d: (struct){ e: (struct){ g: (int){ 1 } } } } } } } t2: (struct){ c: (struct){ c: (struct){ g: (int){ 1 } } g: (int){ 1 } } g: (int){ 1 } } } embeddedFunctionalExpr: (string){ "str" #fn: (string){ "str" #in: (string){ "str" } } #in: (string){ "str" } } } -- out/evalalpha -- (struct){ embeddingDirect: (struct){ t1: (string){ "s" #a: (string){ "s" } } } embeddingExpr: (struct){ t1: (string){ "s" #a: (string){ "s" } } } unifiedDirect: (struct){ t1: (string){ "s" #a: (string){ "s" } } } unifiedExpr: (struct){ t1: (string){ "s" #a: (string){ "s" } } } cross: (struct){ t1: (struct){ a: (struct){ b: (struct){ v: (int){ 1 } a: (struct){ w: (int){ 2 } } y: (int){ 5 } } x: (int){ 2 } w: (int){ 2 } } b: (struct){ a: (struct){ x: (int){ 2 } b: (struct){ y: (int){ 5 } } w: (int){ 2 } } v: (int){ 1 } y: (int){ 5 } } v: (int){ 1 } w: (int){ 2 } x: (int){ 2 } y: (int){ 5 } } } recursive: (struct){ t1: (struct){ e: (struct){ f: (int){ 1 } g: (int){ 1 } } c: (struct){ d: (struct){ e: (struct){ f: (int){ 1 } g: (int){ 1 } } c: (struct){ d: (struct){ e: (struct){ g: (int){ 1 } } } } } } } t2: (struct){ c: (struct){ c: (struct){ g: (int){ 1 } } g: (int){ 1 } } g: (int){ 1 } } } embeddedFunctionalExpr: (string){ "str" #fn: (string){ "str" #in: (string){ "str" } } #in: (string){ "str" } } } -- diff/-out/evalalpha<==>+out/eval -- diff old new --- old +++ new @@ -47,10 +47,10 @@ v: (int){ 1 } y: (int){ 5 } } - x: (int){ 2 } - y: (int){ 5 } v: (int){ 1 } w: (int){ 2 } + x: (int){ 2 } + y: (int){ 5 } } } recursive: (struct){ -- diff/todo/p3 -- Reordering. -- out/compile -- --- a.cue { embeddingDirect: { t1: ({ #a: _ _ } & { #a: "s" 〈0;#a〉 }) } embeddingExpr: { t1: ({ #a: _ _ } & { #a: "s" [ 〈1;#a〉, ][0] }) } unifiedDirect: { t1: { #a: _ _ } t1: { 〈0;#a〉 #a: _ } t1: { _ #a: "s" } } unifiedExpr: { t1: { #a: _ _ } t1: { [ 〈1;#a〉, ][0] #a: _ } t1: { #a: "s" _ } } cross: { t1: { a: { b: { v: 1 a: { w: 2 } } } b: { a: { x: 2 b: { y: 5 } } } 〈0;a〉 〈0;b〉 } } } --- complex.cue { recursive: { t1: { e: {} c: { d: { e: { f: 1 } } } 〈0;c〉.d c: { d: { c: { d: { e: { g: 1 } } } } } } } recursive: { t2: { 〈0;c〉 c: { c: { g: 1 } } } } } --- issue2169.cue { embeddedFunctionalExpr: { #fn: ({ #in: _ _ } & { #in: "str" (({ #t: _ 〈0;#t〉 } & { #t: 〈1;#in〉 _ }) + "") }) 〈0;#fn〉 } }