-- in.cue --
a: {
	{{
		b
		c
		d: b
		e: c
	}}
	c: {}
}
b: {

}
s: "foo"
c: s

// s is technically in a new struct here so it will have a one higher count than
// the one before.
d: [s]: 3

e: {}
e & {// Is this allowed? Probably not as per comprehension rule (ref fixes.)
	e: {}
}

{X=["foo"]: b: X | null}
{[Y="bar"]: b: Y}

let B = {open: int}
f: B

schema: {
	next: _schema_1
}

let _schema_1 = schema
-- out/compile --
--- in.cue
{
  a: {
    {
      {
        〈3;b〉
        〈2;c〉
        d: 〈3;b〉
        e: 〈2;c〉
      }
    }
    c: {}
  }
  b: {}
  s: "foo"
  c: 〈0;s〉
  d: {
    [〈1;s〉]: 3
  }
  e: {}
  (〈0;e〉 & {
    e: {}
  })
  {
    ["foo"]: {
      b: (〈1;(〈0;-〉)〉|null)
    }
  }
  {
    ["bar"]: {
      b: 〈1;-〉
    }
  }
  let B#1 = {
    open: int
  }
  f: 〈0;let B#1〉
  schema: {
    next: 〈1;let _schema_1#2〉
  }
  let _schema_1#2 = 〈0;schema〉
}
-- out/evalalpha/stats --
Leaks:  24
Freed:  0
Reused: 0
Allocs: 24
Retain: 0

Unifications: 22
Conjuncts:    39
Disjuncts:    2

CloseIDElems: 0
NumCloseIDs: 15
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
diff old new
--- old
+++ new
@@ -1,9 +1,12 @@
-Leaks:  2
-Freed:  48
-Reused: 45
-Allocs: 5
-Retain: 8
-
-Unifications: 50
-Conjuncts:    102
-Disjuncts:    54
+Leaks:  24
+Freed:  0
+Reused: 0
+Allocs: 24
+Retain: 0
+
+Unifications: 22
+Conjuncts:    39
+Disjuncts:    2
+
+CloseIDElems: 0
+NumCloseIDs: 15
-- out/eval/stats --
Leaks:  2
Freed:  48
Reused: 45
Allocs: 5
Retain: 8

Unifications: 50
Conjuncts:    102
Disjuncts:    54
-- out/evalalpha --
Errors:
schema.next: structural cycle

Result:
(_|_){
  // [structural cycle]
  a: (struct){
    d: (struct){
    }
    e: (struct){
    }
    c: (struct){
    }
  }
  b: (struct){
  }
  s: (string){ "foo" }
  c: (string){ "foo" }
  d: (struct){
  }
  e: (struct){
  }
  let B#1 = (struct){
    open: (int){ int }
  }
  f: (struct){
    open: (int){ int }
  }
  schema: (_|_){
    // [structural cycle]
    next: (_|_){
      // [structural cycle] schema.next: structural cycle
    }
  }
  let _schema_1#2 = (_|_){
    // [structural cycle]
  }
}
-- diff/-out/evalalpha<==>+out/eval --
diff old new
--- old
+++ new
@@ -33,7 +33,6 @@
     }
   }
   let _schema_1#2 = (_|_){
-    // [structural cycle] _schema_1: structural cycle:
-    //     ./in.cue:32:8
+    // [structural cycle]
   }
 }
-- diff/todo/p3 --
Structural cycle reported in different location. Seems fine, as
ultimately we need to print the paths of the cycle anyway.
Now also reports a position.
-- out/eval --
Errors:
schema.next: structural cycle

Result:
(_|_){
  // [structural cycle]
  a: (struct){
    d: (struct){
    }
    e: (struct){
    }
    c: (struct){
    }
  }
  b: (struct){
  }
  s: (string){ "foo" }
  c: (string){ "foo" }
  d: (struct){
  }
  e: (struct){
  }
  let B#1 = (struct){
    open: (int){ int }
  }
  f: (struct){
    open: (int){ int }
  }
  schema: (_|_){
    // [structural cycle]
    next: (_|_){
      // [structural cycle] schema.next: structural cycle
    }
  }
  let _schema_1#2 = (_|_){
    // [structural cycle] _schema_1: structural cycle:
    //     ./in.cue:32:8
  }
}
