

-- in.cue --
issue3062: ok1: {
	#S: "a"
	#o: x: #S
	o: #o
	o: X
	X: x: A
	A: "a"
}

issue3601: ok1: {
	Y: (X & __no_sharing).a
	X: a: b: a.b
	out: Y & __no_sharing
}

// Test debug facilities to turn of sharing.
debug: {
	sharingOn: {
		a: b
		b: c: 1
	}
	sharingOff: t1: {
		a: b & __no_sharing
		b: c: 1
	}
	sharingOff: t2: {
		a: b
		a: __no_sharing
		b: c: 1
	}
	sharingOff: t3: {
		a: __no_sharing
		a: b
		b: c: 1
	}
}
-- dupshare.cue --
// This file contains tests where unifying the same field multiple times into
// a field with different "closedness" history should compute closedness
// correctly.

issue3641: simplified: t1: {
	#Context1: ctx: {}
	Context2: ctx: {}

	// Must both refer to #Context1
	#Config1: cfg: #Context1
	#Config3: cfg: #Context1

	Config2: cfg: Context2

	Config: #Config1 & Config2

	// order matters
	out: Config // Indirection necessary.
	out: #Config3
}
issue3641: simplified: t2: {
	#Context1: ctx: {}
	Context2: ctx: {}

	// Must both refer to #Context1
	#Config1: cfg: #Context1
	#Config3: cfg: #Context1

	Config2: cfg: Context2
	
	Config: #Config1 & Config2

	// order matters
	out: Config // Indirection necessary.
	out: #Config3
}
// Variant where sharing is explicitly disabled.
issue3641: simplified: t3: {
	#Context1: ctx: {}
	Context2: ctx: {}

	// Must both refer to #Context1
	#Config1: cfg: #Context1
	#Config3: cfg: #Context1

	Config2: cfg: Context2

	Config: #Config1 & Config2

	// order matters
	out: __no_sharing
	out: Config // Indirection necessary.
	out: #Config3
}
issue3641: full: {
	#Context1: ctx: {}
	#Context2: ctx: {}

	#Config1: cfg: #Context1
	#Config2: cfg: #Context2

	#Schema: sch: #Config1

	#Config: #Config1 & #Config2

	let config = #Config
	out: #Schema & {
		sch: config
	}
}
issue3546: reduced: {
	all: ["a"]
	#all: all

	#Network: list: #List
	#List: [...string]

	val: #Network
	val: list: #all

	out: #Network
	out: val
}
-- sharecycle.cue --
shareCycle: t1: {
	#X: {}
	Y: {
		x: #X & Y
	}
}
shareCycle: t2: {
	#X: int
	Y: {
		x: #X & Y
	}
}
shareCycle: t3: {
	#X: {}
	Y: {
		x: Y & #X
	}
}
-- acrossdisjunction.cue --
import "list"

issue3679: {
	// The result of list.Repeat is structure shared in env. This needs to be
	// "unshared" within the disjunction. Ensure that unsharing a shared Vertex
	// works arcross disjunction boundaries.
	b: null | [string]
	b: list.Repeat([for k, v in [0] { "bar" }], 1)
}
-- issue3835.cue --
issue3835: {
	foo: {}

	_global: "global value"

	[string]: {
		if true let orgBotUser = _global {
			out: "prefix: " + orgBotUser
		}
	}
}
-- pendingarcs.cue --
pending: t1: {
	a: X
	if true {
		a: b: c: e: 1
	}
	X: b: Y
	Y: c: d: int
}
issue3849: {
	dep: #Deployment & {}
	if true {
		dep: metadata: name: app: "mysql"
	}
	#Deployment: metadata?: #ObjectMeta
	#ObjectMeta: name?: [string]: string
}
-- let.cue --
import "list"

issue3903: full: {
	_input: null | *{name: "foo"}

	let _inputList = list.FlattenN([_input], 0)

	_inputByName: {
		for input in _inputList {
			(input.name): input
		}
	}

	for name, _input in _inputByName {
		(name): _template & {
			input: _input
		}
	}
	_template: {
		input: name: string
		result: "result-\(input.name)"
	}
}
issue3903: noshare: {
	_input: null | *{name: "foo"}

	let _inputList = list.FlattenN([_input], 0)

	_inputByName: {
		for input in (_inputList & __no_sharing) {
			(input.name): input
		}
	}
	for name, _input in _inputByName {
		(name): _template & {
			input: _input
		}
	}
	_template: {
		input:  name: string
		result: "result-\(input.name)"
	}
}
-- out/eval/stats --
Leaks:  12
Freed:  266
Reused: 260
Allocs: 18
Retain: 36

Unifications: 252
Conjuncts:    523
Disjuncts:    305
-- out/evalalpha --
Errors:
shareCycle.t1.Y.x.x: structural cycle
shareCycle.t2.Y.x: conflicting values int and {x:(#X & Y)} (mismatched types int and struct):
    ./sharecycle.cue:8:6
    ./sharecycle.cue:9:5
shareCycle.t3.Y.x.x: structural cycle

Result:
(_|_){
  // [eval]
  issue3679: (struct){
    b: (#list){
      0: (string){ "bar" }
    }
  }
  issue3641: (struct){
    simplified: (struct){
      t1: (struct){
        #Context1: (#struct){
          ctx: (#struct){
          }
        }
        Context2: (struct){
          ctx: (struct){
          }
        }
        #Config1: (#struct){
          cfg: ~(issue3641.simplified.t1.#Context1)
        }
        #Config3: (#struct){
          cfg: ~(issue3641.simplified.t1.#Context1)
        }
        Config2: (struct){
          cfg: ~(issue3641.simplified.t1.Context2)
        }
        Config: (#struct){
          cfg: (#struct){
            ctx: (#struct){
            }
          }
        }
        out: (#struct){
          cfg: (#struct){
            ctx: (#struct){
            }
          }
        }
      }
      t2: (struct){
        #Context1: (#struct){
          ctx: (#struct){
          }
        }
        Context2: (struct){
          ctx: (struct){
          }
        }
        #Config1: (#struct){
          cfg: ~(issue3641.simplified.t2.#Context1)
        }
        #Config3: (#struct){
          cfg: ~(issue3641.simplified.t2.#Context1)
        }
        Config2: (struct){
          cfg: ~(issue3641.simplified.t2.Context2)
        }
        Config: (#struct){
          cfg: (#struct){
            ctx: (#struct){
            }
          }
        }
        out: (#struct){
          cfg: (#struct){
            ctx: (#struct){
            }
          }
        }
      }
      t3: (struct){
        #Context1: (#struct){
          ctx: (#struct){
          }
        }
        Context2: (struct){
          ctx: (struct){
          }
        }
        #Config1: (#struct){
          cfg: ~(issue3641.simplified.t3.#Context1)
        }
        #Config3: (#struct){
          cfg: ~(issue3641.simplified.t3.#Context1)
        }
        Config2: (struct){
          cfg: ~(issue3641.simplified.t3.Context2)
        }
        Config: (#struct){
          cfg: (#struct){
            ctx: (#struct){
            }
          }
        }
        out: (#struct){
          cfg: (#struct){
            ctx: (#struct){
            }
          }
        }
      }
    }
    full: (struct){
      #Context1: (#struct){
        ctx: (#struct){
        }
      }
      #Context2: (#struct){
        ctx: (#struct){
        }
      }
      #Config1: (#struct){
        cfg: ~(issue3641.full.#Context1)
      }
      #Config2: (#struct){
        cfg: ~(issue3641.full.#Context2)
      }
      #Schema: (#struct){
        sch: ~(issue3641.full.#Config1)
      }
      #Config: (#struct){
        cfg: (#struct){
          ctx: (#struct){
          }
        }
      }
      let config#1 = ~(issue3641.full.#Config)
      out: (#struct){
        sch: (#struct){
          cfg: (#struct){
            ctx: (#struct){
            }
          }
        }
      }
    }
  }
  issue3546: (struct){
    reduced: (struct){
      all: (#list){
        0: (string){ "a" }
      }
      #all: (#list){
        0: (string){ "a" }
      }
      #Network: (#struct){
        list: (list){
        }
      }
      #List: (list){
      }
      val: (#struct){
        list: (#list){
          0: (string){ "a" }
        }
      }
      out: (#struct){
        list: (#list){
          0: (string){ "a" }
        }
      }
    }
  }
  issue3062: (struct){
    ok1: (struct){
      #S: (string){ "a" }
      #o: (#struct){
        x: (string){ "a" }
      }
      o: (#struct){
        x: (string){ "a" }
      }
      X: (struct){
        x: (string){ "a" }
      }
      A: (string){ "a" }
    }
  }
  issue3601: (struct){
    ok1: (struct){
      Y: (struct){
        b: (_){ _ }
      }
      X: (struct){
        a: (struct){
          b: (_){ _ }
        }
      }
      out: (struct){
        b: (_){ _ }
      }
    }
  }
  debug: (struct){
    sharingOn: (struct){
      a: ~(debug.sharingOn.b)
      b: (struct){
        c: (int){ 1 }
      }
    }
    sharingOff: (struct){
      t1: (struct){
        a: (struct){
          c: (int){ 1 }
        }
        b: (struct){
          c: (int){ 1 }
        }
      }
      t2: (struct){
        a: (struct){
          c: (int){ 1 }
        }
        b: (struct){
          c: (int){ 1 }
        }
      }
      t3: (struct){
        a: (struct){
          c: (int){ 1 }
        }
        b: (struct){
          c: (int){ 1 }
        }
      }
    }
  }
  issue3835: (struct){
    foo: (struct){
      out: (string){ "prefix: global value" }
    }
    _global: (string){ "global value" }
  }
  issue3903: (struct){
    full: (struct){
      _input: ((null|struct)){ |(*(struct){
          name: (string){ "foo" }
        }, (null){ null }) }
      let _inputList#2 = (#list){
        0: (struct){
          name: (string){ "foo" }
        }
      }
      _inputByName: (struct){
        foo: ~(issue3903.full._input)
      }
      _template: (struct){
        input: (struct){
          name: (string){ string }
        }
        result: (_|_){
          // [incomplete] issue3903.full._template.result: invalid interpolation: non-concrete value string (type string):
          //     ./let.cue:21:11
          //     ./let.cue:20:16
        }
      }
      foo: (struct){
        input: (struct){
          name: (string){ "foo" }
        }
        result: (string){ "result-foo" }
      }
    }
    noshare: (struct){
      _input: ((null|struct)){ |(*(struct){
          name: (string){ "foo" }
        }, (null){ null }) }
      let _inputList#3 = (#list){
        0: (struct){
          name: (string){ "foo" }
        }
      }
      _inputByName: (struct){
        foo: (struct){
          name: (string){ "foo" }
        }
      }
      _template: (struct){
        input: (struct){
          name: (string){ string }
        }
        result: (_|_){
          // [incomplete] issue3903.noshare._template.result: invalid interpolation: non-concrete value string (type string):
          //     ./let.cue:41:11
          //     ./let.cue:40:17
        }
      }
      foo: (struct){
        input: (struct){
          name: (string){ string }
        }
        result: (_|_){
          // [incomplete] issue3903.noshare.foo.result: invalid interpolation: non-concrete value string (type string):
          //     ./let.cue:41:11
          //     ./let.cue:40:17
        }
      }
    }
  }
  pending: (struct){
    t1: (struct){
      a: (struct){
        b: (struct){
          c: (struct){
            e: (int){ 1 }
            d: (int){ int }
          }
        }
      }
      X: (struct){
        b: ~(pending.t1.Y)
      }
      Y: (struct){
        c: (struct){
          d: (int){ int }
        }
      }
    }
  }
  issue3849: (struct){
    dep: (#struct){
      metadata: (#struct){
        name: (#struct){
          app: (string){ "mysql" }
        }
      }
    }
    #Deployment: (#struct){
      metadata?: ~(issue3849.#ObjectMeta)
    }
    #ObjectMeta: (#struct){
      name?: (#struct){
      }
    }
  }
  shareCycle: (_|_){
    // [eval]
    t1: (_|_){
      // [structural cycle]
      #X: (#struct){
      }
      Y: (_|_){
        // [structural cycle]
        x: (_|_){
          // [structural cycle]
          x: (_|_){
            // [structural cycle] shareCycle.t1.Y.x.x: structural cycle
          }
        }
      }
    }
    t2: (_|_){
      // [eval]
      #X: (int){ int }
      Y: (_|_){
        // [eval]
        x: (_|_){
          // [eval] shareCycle.t2.Y.x: conflicting values int and {x:(#X & Y)} (mismatched types int and struct):
          //     ./sharecycle.cue:8:6
          //     ./sharecycle.cue:9:5
          x: (_|_){// (〈1;#X〉 & 〈1;Y〉)
          }
        }
      }
    }
    t3: (_|_){
      // [structural cycle]
      #X: (#struct){
      }
      Y: (_|_){
        // [structural cycle]
        x: (_|_){
          // [structural cycle]
          x: (_|_){
            // [structural cycle] shareCycle.t3.Y.x.x: structural cycle
          }
        }
      }
    }
  }
}
-- diff/-out/evalalpha<==>+out/eval --
diff old new
--- old
+++ new
@@ -3,8 +3,6 @@
 shareCycle.t2.Y.x: conflicting values int and {x:(#X & Y)} (mismatched types int and struct):
     ./sharecycle.cue:8:6
     ./sharecycle.cue:9:5
-    ./sharecycle.cue:10:11
-shareCycle.t2.Y.x.x: structural cycle
 shareCycle.t3.Y.x.x: structural cycle
 
 Result:
@@ -27,102 +25,75 @@
           }
         }
         #Config1: (#struct){
-          cfg: (#struct){
-            ctx: (#struct){
-            }
-          }
-        }
-        #Config3: (#struct){
-          cfg: (#struct){
-            ctx: (#struct){
-            }
-          }
-        }
-        Config2: (struct){
-          cfg: (struct){
-            ctx: (struct){
-            }
-          }
-        }
-        Config: (#struct){
-          cfg: (#struct){
-            ctx: (#struct){
-            }
-          }
-        }
-        out: (#struct){
-          cfg: (#struct){
-            ctx: (#struct){
-            }
-          }
-        }
-      }
-      t2: (struct){
-        #Context1: (#struct){
-          ctx: (#struct){
-          }
-        }
-        Context2: (struct){
-          ctx: (struct){
-          }
-        }
-        #Config1: (#struct){
-          cfg: (#struct){
-            ctx: (#struct){
-            }
-          }
-        }
-        #Config3: (#struct){
-          cfg: (#struct){
-            ctx: (#struct){
-            }
-          }
-        }
-        Config2: (struct){
-          cfg: (struct){
-            ctx: (struct){
-            }
-          }
-        }
-        Config: (#struct){
-          cfg: (#struct){
-            ctx: (#struct){
-            }
-          }
-        }
-        out: (#struct){
-          cfg: (#struct){
-            ctx: (#struct){
-            }
-          }
-        }
-      }
-      t3: (struct){
-        #Context1: (#struct){
-          ctx: (#struct){
-          }
-        }
-        Context2: (struct){
-          ctx: (struct){
-          }
-        }
-        #Config1: (#struct){
-          cfg: (#struct){
-            ctx: (#struct){
-            }
-          }
-        }
-        #Config3: (#struct){
-          cfg: (#struct){
-            ctx: (#struct){
-            }
-          }
-        }
-        Config2: (struct){
-          cfg: (struct){
-            ctx: (struct){
-            }
-          }
+          cfg: ~(issue3641.simplified.t1.#Context1)
+        }
+        #Config3: (#struct){
+          cfg: ~(issue3641.simplified.t1.#Context1)
+        }
+        Config2: (struct){
+          cfg: ~(issue3641.simplified.t1.Context2)
+        }
+        Config: (#struct){
+          cfg: (#struct){
+            ctx: (#struct){
+            }
+          }
+        }
+        out: (#struct){
+          cfg: (#struct){
+            ctx: (#struct){
+            }
+          }
+        }
+      }
+      t2: (struct){
+        #Context1: (#struct){
+          ctx: (#struct){
+          }
+        }
+        Context2: (struct){
+          ctx: (struct){
+          }
+        }
+        #Config1: (#struct){
+          cfg: ~(issue3641.simplified.t2.#Context1)
+        }
+        #Config3: (#struct){
+          cfg: ~(issue3641.simplified.t2.#Context1)
+        }
+        Config2: (struct){
+          cfg: ~(issue3641.simplified.t2.Context2)
+        }
+        Config: (#struct){
+          cfg: (#struct){
+            ctx: (#struct){
+            }
+          }
+        }
+        out: (#struct){
+          cfg: (#struct){
+            ctx: (#struct){
+            }
+          }
+        }
+      }
+      t3: (struct){
+        #Context1: (#struct){
+          ctx: (#struct){
+          }
+        }
+        Context2: (struct){
+          ctx: (struct){
+          }
+        }
+        #Config1: (#struct){
+          cfg: ~(issue3641.simplified.t3.#Context1)
+        }
+        #Config3: (#struct){
+          cfg: ~(issue3641.simplified.t3.#Context1)
+        }
+        Config2: (struct){
+          cfg: ~(issue3641.simplified.t3.Context2)
         }
         Config: (#struct){
           cfg: (#struct){
@@ -148,24 +119,13 @@
         }
       }
       #Config1: (#struct){
-        cfg: (#struct){
-          ctx: (#struct){
-          }
-        }
+        cfg: ~(issue3641.full.#Context1)
       }
       #Config2: (#struct){
-        cfg: (#struct){
-          ctx: (#struct){
-          }
-        }
+        cfg: ~(issue3641.full.#Context2)
       }
       #Schema: (#struct){
-        sch: (#struct){
-          cfg: (#struct){
-            ctx: (#struct){
-            }
-          }
-        }
+        sch: ~(issue3641.full.#Config1)
       }
       #Config: (#struct){
         cfg: (#struct){
@@ -173,12 +133,7 @@
           }
         }
       }
-      let config#1 = (#struct){
-        cfg: (#struct){
-          ctx: (#struct){
-          }
-        }
-      }
+      let config#1 = ~(issue3641.full.#Config)
       out: (#struct){
         sch: (#struct){
           cfg: (#struct){
@@ -247,9 +202,7 @@
   }
   debug: (struct){
     sharingOn: (struct){
-      a: (struct){
-        c: (int){ 1 }
-      }
+      a: ~(debug.sharingOn.b)
       b: (struct){
         c: (int){ 1 }
       }
@@ -293,14 +246,12 @@
           name: (string){ "foo" }
         }, (null){ null }) }
       let _inputList#2 = (#list){
-        0: ((null|struct)){ |(*(struct){
-            name: (string){ "foo" }
-          }, (null){ null }) }
-      }
-      _inputByName: (struct){
-        foo: ((null|struct)){ |(*(struct){
-            name: (string){ "foo" }
-          }, (null){ null }) }
+        0: (struct){
+          name: (string){ "foo" }
+        }
+      }
+      _inputByName: (struct){
+        foo: ~(issue3903.full._input)
       }
       _template: (struct){
         input: (struct){
@@ -324,14 +275,14 @@
           name: (string){ "foo" }
         }, (null){ null }) }
       let _inputList#3 = (#list){
-        0: ((null|struct)){ |(*(struct){
-            name: (string){ "foo" }
-          }, (null){ null }) }
-      }
-      _inputByName: (struct){
-        foo: ((null|struct)){ |(*(struct){
-            name: (string){ "foo" }
-          }, (null){ null }) }
+        0: (struct){
+          name: (string){ "foo" }
+        }
+      }
+      _inputByName: (struct){
+        foo: (struct){
+          name: (string){ "foo" }
+        }
       }
       _template: (struct){
         input: (struct){
@@ -345,9 +296,13 @@
       }
       foo: (struct){
         input: (struct){
-          name: (string){ "foo" }
-        }
-        result: (string){ "result-foo" }
+          name: (string){ string }
+        }
+        result: (_|_){
+          // [incomplete] issue3903.noshare.foo.result: invalid interpolation: non-concrete value string (type string):
+          //     ./let.cue:41:11
+          //     ./let.cue:40:17
+        }
       }
     }
   }
@@ -356,17 +311,13 @@
       a: (struct){
         b: (struct){
           c: (struct){
-            d: (int){ int }
             e: (int){ 1 }
-          }
-        }
-      }
-      X: (struct){
-        b: (struct){
-          c: (struct){
-            d: (int){ int }
-          }
-        }
+            d: (int){ int }
+          }
+        }
+      }
+      X: (struct){
+        b: ~(pending.t1.Y)
       }
       Y: (struct){
         c: (struct){
@@ -384,10 +335,7 @@
       }
     }
     #Deployment: (#struct){
-      metadata?: (#struct){
-        name?: (#struct){
-        }
-      }
+      metadata?: ~(issue3849.#ObjectMeta)
     }
     #ObjectMeta: (#struct){
       name?: (#struct){
@@ -419,9 +367,7 @@
           // [eval] shareCycle.t2.Y.x: conflicting values int and {x:(#X & Y)} (mismatched types int and struct):
           //     ./sharecycle.cue:8:6
           //     ./sharecycle.cue:9:5
-          //     ./sharecycle.cue:10:11
-          x: (_|_){
-            // [structural cycle] shareCycle.t2.Y.x.x: structural cycle
+          x: (_|_){// (〈1;#X〉 & 〈1;Y〉)
           }
         }
       }
-- diff/todo/p2 --
issue3903.noshare.foo: should be error free, like with the full version.
-- out/eval --
Errors:
shareCycle.t1.Y.x.x: structural cycle
shareCycle.t2.Y.x: conflicting values int and {x:(#X & Y)} (mismatched types int and struct):
    ./sharecycle.cue:8:6
    ./sharecycle.cue:9:5
    ./sharecycle.cue:10:11
shareCycle.t2.Y.x.x: structural cycle
shareCycle.t3.Y.x.x: structural cycle

Result:
(_|_){
  // [eval]
  issue3679: (struct){
    b: (#list){
      0: (string){ "bar" }
    }
  }
  issue3641: (struct){
    simplified: (struct){
      t1: (struct){
        #Context1: (#struct){
          ctx: (#struct){
          }
        }
        Context2: (struct){
          ctx: (struct){
          }
        }
        #Config1: (#struct){
          cfg: (#struct){
            ctx: (#struct){
            }
          }
        }
        #Config3: (#struct){
          cfg: (#struct){
            ctx: (#struct){
            }
          }
        }
        Config2: (struct){
          cfg: (struct){
            ctx: (struct){
            }
          }
        }
        Config: (#struct){
          cfg: (#struct){
            ctx: (#struct){
            }
          }
        }
        out: (#struct){
          cfg: (#struct){
            ctx: (#struct){
            }
          }
        }
      }
      t2: (struct){
        #Context1: (#struct){
          ctx: (#struct){
          }
        }
        Context2: (struct){
          ctx: (struct){
          }
        }
        #Config1: (#struct){
          cfg: (#struct){
            ctx: (#struct){
            }
          }
        }
        #Config3: (#struct){
          cfg: (#struct){
            ctx: (#struct){
            }
          }
        }
        Config2: (struct){
          cfg: (struct){
            ctx: (struct){
            }
          }
        }
        Config: (#struct){
          cfg: (#struct){
            ctx: (#struct){
            }
          }
        }
        out: (#struct){
          cfg: (#struct){
            ctx: (#struct){
            }
          }
        }
      }
      t3: (struct){
        #Context1: (#struct){
          ctx: (#struct){
          }
        }
        Context2: (struct){
          ctx: (struct){
          }
        }
        #Config1: (#struct){
          cfg: (#struct){
            ctx: (#struct){
            }
          }
        }
        #Config3: (#struct){
          cfg: (#struct){
            ctx: (#struct){
            }
          }
        }
        Config2: (struct){
          cfg: (struct){
            ctx: (struct){
            }
          }
        }
        Config: (#struct){
          cfg: (#struct){
            ctx: (#struct){
            }
          }
        }
        out: (#struct){
          cfg: (#struct){
            ctx: (#struct){
            }
          }
        }
      }
    }
    full: (struct){
      #Context1: (#struct){
        ctx: (#struct){
        }
      }
      #Context2: (#struct){
        ctx: (#struct){
        }
      }
      #Config1: (#struct){
        cfg: (#struct){
          ctx: (#struct){
          }
        }
      }
      #Config2: (#struct){
        cfg: (#struct){
          ctx: (#struct){
          }
        }
      }
      #Schema: (#struct){
        sch: (#struct){
          cfg: (#struct){
            ctx: (#struct){
            }
          }
        }
      }
      #Config: (#struct){
        cfg: (#struct){
          ctx: (#struct){
          }
        }
      }
      let config#1 = (#struct){
        cfg: (#struct){
          ctx: (#struct){
          }
        }
      }
      out: (#struct){
        sch: (#struct){
          cfg: (#struct){
            ctx: (#struct){
            }
          }
        }
      }
    }
  }
  issue3546: (struct){
    reduced: (struct){
      all: (#list){
        0: (string){ "a" }
      }
      #all: (#list){
        0: (string){ "a" }
      }
      #Network: (#struct){
        list: (list){
        }
      }
      #List: (list){
      }
      val: (#struct){
        list: (#list){
          0: (string){ "a" }
        }
      }
      out: (#struct){
        list: (#list){
          0: (string){ "a" }
        }
      }
    }
  }
  issue3062: (struct){
    ok1: (struct){
      #S: (string){ "a" }
      #o: (#struct){
        x: (string){ "a" }
      }
      o: (#struct){
        x: (string){ "a" }
      }
      X: (struct){
        x: (string){ "a" }
      }
      A: (string){ "a" }
    }
  }
  issue3601: (struct){
    ok1: (struct){
      Y: (struct){
        b: (_){ _ }
      }
      X: (struct){
        a: (struct){
          b: (_){ _ }
        }
      }
      out: (struct){
        b: (_){ _ }
      }
    }
  }
  debug: (struct){
    sharingOn: (struct){
      a: (struct){
        c: (int){ 1 }
      }
      b: (struct){
        c: (int){ 1 }
      }
    }
    sharingOff: (struct){
      t1: (struct){
        a: (struct){
          c: (int){ 1 }
        }
        b: (struct){
          c: (int){ 1 }
        }
      }
      t2: (struct){
        a: (struct){
          c: (int){ 1 }
        }
        b: (struct){
          c: (int){ 1 }
        }
      }
      t3: (struct){
        a: (struct){
          c: (int){ 1 }
        }
        b: (struct){
          c: (int){ 1 }
        }
      }
    }
  }
  issue3835: (struct){
    foo: (struct){
      out: (string){ "prefix: global value" }
    }
    _global: (string){ "global value" }
  }
  issue3903: (struct){
    full: (struct){
      _input: ((null|struct)){ |(*(struct){
          name: (string){ "foo" }
        }, (null){ null }) }
      let _inputList#2 = (#list){
        0: ((null|struct)){ |(*(struct){
            name: (string){ "foo" }
          }, (null){ null }) }
      }
      _inputByName: (struct){
        foo: ((null|struct)){ |(*(struct){
            name: (string){ "foo" }
          }, (null){ null }) }
      }
      _template: (struct){
        input: (struct){
          name: (string){ string }
        }
        result: (_|_){
          // [incomplete] issue3903.full._template.result: invalid interpolation: non-concrete value string (type string):
          //     ./let.cue:21:11
          //     ./let.cue:20:16
        }
      }
      foo: (struct){
        input: (struct){
          name: (string){ "foo" }
        }
        result: (string){ "result-foo" }
      }
    }
    noshare: (struct){
      _input: ((null|struct)){ |(*(struct){
          name: (string){ "foo" }
        }, (null){ null }) }
      let _inputList#3 = (#list){
        0: ((null|struct)){ |(*(struct){
            name: (string){ "foo" }
          }, (null){ null }) }
      }
      _inputByName: (struct){
        foo: ((null|struct)){ |(*(struct){
            name: (string){ "foo" }
          }, (null){ null }) }
      }
      _template: (struct){
        input: (struct){
          name: (string){ string }
        }
        result: (_|_){
          // [incomplete] issue3903.noshare._template.result: invalid interpolation: non-concrete value string (type string):
          //     ./let.cue:41:11
          //     ./let.cue:40:17
        }
      }
      foo: (struct){
        input: (struct){
          name: (string){ "foo" }
        }
        result: (string){ "result-foo" }
      }
    }
  }
  pending: (struct){
    t1: (struct){
      a: (struct){
        b: (struct){
          c: (struct){
            d: (int){ int }
            e: (int){ 1 }
          }
        }
      }
      X: (struct){
        b: (struct){
          c: (struct){
            d: (int){ int }
          }
        }
      }
      Y: (struct){
        c: (struct){
          d: (int){ int }
        }
      }
    }
  }
  issue3849: (struct){
    dep: (#struct){
      metadata: (#struct){
        name: (#struct){
          app: (string){ "mysql" }
        }
      }
    }
    #Deployment: (#struct){
      metadata?: (#struct){
        name?: (#struct){
        }
      }
    }
    #ObjectMeta: (#struct){
      name?: (#struct){
      }
    }
  }
  shareCycle: (_|_){
    // [eval]
    t1: (_|_){
      // [structural cycle]
      #X: (#struct){
      }
      Y: (_|_){
        // [structural cycle]
        x: (_|_){
          // [structural cycle]
          x: (_|_){
            // [structural cycle] shareCycle.t1.Y.x.x: structural cycle
          }
        }
      }
    }
    t2: (_|_){
      // [eval]
      #X: (int){ int }
      Y: (_|_){
        // [eval]
        x: (_|_){
          // [eval] shareCycle.t2.Y.x: conflicting values int and {x:(#X & Y)} (mismatched types int and struct):
          //     ./sharecycle.cue:8:6
          //     ./sharecycle.cue:9:5
          //     ./sharecycle.cue:10:11
          x: (_|_){
            // [structural cycle] shareCycle.t2.Y.x.x: structural cycle
          }
        }
      }
    }
    t3: (_|_){
      // [structural cycle]
      #X: (#struct){
      }
      Y: (_|_){
        // [structural cycle]
        x: (_|_){
          // [structural cycle]
          x: (_|_){
            // [structural cycle] shareCycle.t3.Y.x.x: structural cycle
          }
        }
      }
    }
  }
}
-- out/compile --
--- acrossdisjunction.cue
{
  issue3679: {
    b: (null|[
      string,
    ])
    b: 〈import;list〉.Repeat([
      for k, v in [
        0,
      ] {
        "bar"
      },
    ], 1)
  }
}
--- dupshare.cue
{
  issue3641: {
    simplified: {
      t1: {
        #Context1: {
          ctx: {}
        }
        Context2: {
          ctx: {}
        }
        #Config1: {
          cfg: 〈1;#Context1〉
        }
        #Config3: {
          cfg: 〈1;#Context1〉
        }
        Config2: {
          cfg: 〈1;Context2〉
        }
        Config: (〈0;#Config1〉 & 〈0;Config2〉)
        out: 〈0;Config〉
        out: 〈0;#Config3〉
      }
    }
  }
  issue3641: {
    simplified: {
      t2: {
        #Context1: {
          ctx: {}
        }
        Context2: {
          ctx: {}
        }
        #Config1: {
          cfg: 〈1;#Context1〉
        }
        #Config3: {
          cfg: 〈1;#Context1〉
        }
        Config2: {
          cfg: 〈1;Context2〉
        }
        Config: (〈0;#Config1〉 & 〈0;Config2〉)
        out: 〈0;Config〉
        out: 〈0;#Config3〉
      }
    }
  }
  issue3641: {
    simplified: {
      t3: {
        #Context1: {
          ctx: {}
        }
        Context2: {
          ctx: {}
        }
        #Config1: {
          cfg: 〈1;#Context1〉
        }
        #Config3: {
          cfg: 〈1;#Context1〉
        }
        Config2: {
          cfg: 〈1;Context2〉
        }
        Config: (〈0;#Config1〉 & 〈0;Config2〉)
        out: _|_(no sharing)
        out: 〈0;Config〉
        out: 〈0;#Config3〉
      }
    }
  }
  issue3641: {
    full: {
      #Context1: {
        ctx: {}
      }
      #Context2: {
        ctx: {}
      }
      #Config1: {
        cfg: 〈1;#Context1〉
      }
      #Config2: {
        cfg: 〈1;#Context2〉
      }
      #Schema: {
        sch: 〈1;#Config1〉
      }
      #Config: (〈0;#Config1〉 & 〈0;#Config2〉)
      let config#1 = 〈0;#Config〉
      out: (〈0;#Schema〉 & {
        sch: 〈1;let config#1〉
      })
    }
  }
  issue3546: {
    reduced: {
      all: [
        "a",
      ]
      #all: 〈0;all〉
      #Network: {
        list: 〈1;#List〉
      }
      #List: [
        ...string,
      ]
      val: 〈0;#Network〉
      val: {
        list: 〈1;#all〉
      }
      out: 〈0;#Network〉
      out: 〈0;val〉
    }
  }
}
--- in.cue
{
  issue3062: {
    ok1: {
      #S: "a"
      #o: {
        x: 〈1;#S〉
      }
      o: 〈0;#o〉
      o: 〈0;X〉
      X: {
        x: 〈1;A〉
      }
      A: "a"
    }
  }
  issue3601: {
    ok1: {
      Y: (〈0;X〉 & _|_(no sharing)).a
      X: {
        a: {
          b: 〈1;a〉.b
        }
      }
      out: (〈0;Y〉 & _|_(no sharing))
    }
  }
  debug: {
    sharingOn: {
      a: 〈0;b〉
      b: {
        c: 1
      }
    }
    sharingOff: {
      t1: {
        a: (〈0;b〉 & _|_(no sharing))
        b: {
          c: 1
        }
      }
    }
    sharingOff: {
      t2: {
        a: 〈0;b〉
        a: _|_(no sharing)
        b: {
          c: 1
        }
      }
    }
    sharingOff: {
      t3: {
        a: _|_(no sharing)
        a: 〈0;b〉
        b: {
          c: 1
        }
      }
    }
  }
}
--- issue3835.cue
{
  issue3835: {
    foo: {}
    _global: "global value"
    [string]: {
      if true let orgBotUser = 〈1;_global〉 {
        out: ("prefix: " + 〈1;orgBotUser〉)
      }
    }
  }
}
--- let.cue
{
  issue3903: {
    full: {
      _input: (null|*{
        name: "foo"
      })
      let _inputList#2 = 〈import;list〉.FlattenN([
        〈1;_input〉,
      ], 0)
      _inputByName: {
        for _, input in 〈1;let _inputList#2〉 {
          〈1;input〉.name: 〈1;input〉
        }
      }
      for name, _input in 〈0;_inputByName〉 {
        〈1;name〉: (〈2;_template〉 & {
          input: 〈2;_input〉
        })
      }
      _template: {
        input: {
          name: string
        }
        result: "result-\(〈0;input〉.name)"
      }
    }
  }
  issue3903: {
    noshare: {
      _input: (null|*{
        name: "foo"
      })
      let _inputList#3 = 〈import;list〉.FlattenN([
        〈1;_input〉,
      ], 0)
      _inputByName: {
        for _, input in (〈1;let _inputList#3〉 & _|_(no sharing)) {
          〈1;input〉.name: 〈1;input〉
        }
      }
      for name, _input in 〈0;_inputByName〉 {
        〈1;name〉: (〈2;_template〉 & {
          input: 〈2;_input〉
        })
      }
      _template: {
        input: {
          name: string
        }
        result: "result-\(〈0;input〉.name)"
      }
    }
  }
}
--- pendingarcs.cue
{
  pending: {
    t1: {
      a: 〈0;X〉
      if true {
        a: {
          b: {
            c: {
              e: 1
            }
          }
        }
      }
      X: {
        b: 〈1;Y〉
      }
      Y: {
        c: {
          d: int
        }
      }
    }
  }
  issue3849: {
    dep: (〈0;#Deployment〉 & {})
    if true {
      dep: {
        metadata: {
          name: {
            app: "mysql"
          }
        }
      }
    }
    #Deployment: {
      metadata?: 〈1;#ObjectMeta〉
    }
    #ObjectMeta: {
      name?: {
        [string]: string
      }
    }
  }
}
--- sharecycle.cue
{
  shareCycle: {
    t1: {
      #X: {}
      Y: {
        x: (〈1;#X〉 & 〈1;Y〉)
      }
    }
  }
  shareCycle: {
    t2: {
      #X: int
      Y: {
        x: (〈1;#X〉 & 〈1;Y〉)
      }
    }
  }
  shareCycle: {
    t3: {
      #X: {}
      Y: {
        x: (〈1;Y〉 & 〈1;#X〉)
      }
    }
  }
}
