// Excluded from V2, which no longer passes.
#skip-v2
// Lots of cycle-reference goodness.

-- in.cue --
[!~"^[.]"]: c
a:          b
b: [string]: int
c: a:        int
[string]: c
a:        b
b: [string]: int
c: a:        int

-- issue3326.cue --
issue3326: {
	// This issue triggered a cyclic evaluation in pattern constraints.
	//
	// It seems like there is still an issue as the evaluation of `x` in
	// `and` may trigger a cyclic evaluation of `and`. However, `and` only
	// does a shallow evaluation, and inserting `x`'s conjuncts into itself
	// is identified as idempotent and thus further evaluation is skipped.
	_self: x: [...and(x)]
	_self
	x: [1]
}
-- out/eval/stats --
Leaks:  0
Freed:  7
Reused: 2
Allocs: 5
Retain: 2

Unifications: 7
Conjuncts:    59
Disjuncts:    9
-- out/evalalpha --
(struct){
  a: (struct){
    a: (int){ int }
  }
  b: (struct){
    a: (int){ int }
  }
  c: (struct){
    a: (int){ int }
  }
  issue3326: (struct){
    _self: (struct){
      x: (list){
      }
    }
    x: (#list){
      0: (int){ 1 }
    }
    a: (int){ int }
  }
}
-- diff/-out/evalalpha<==>+out/eval --
diff old new
--- old
+++ new
@@ -8,4 +8,14 @@
   c: (struct){
     a: (int){ int }
   }
+  issue3326: (struct){
+    _self: (struct){
+      x: (list){
+      }
+    }
+    x: (#list){
+      0: (int){ 1 }
+    }
+    a: (int){ int }
+  }
 }
-- out/eval --
(struct){
  a: (struct){
    a: (int){ int }
  }
  b: (struct){
    a: (int){ int }
  }
  c: (struct){
    a: (int){ int }
  }
}
-- out/compile --
--- in.cue
{
  [!~"^[.]"]: 〈0;c〉
  a: 〈0;b〉
  b: {
    [string]: int
  }
  c: {
    a: int
  }
  [string]: 〈0;c〉
  a: 〈0;b〉
  b: {
    [string]: int
  }
  c: {
    a: int
  }
}
--- issue3326.cue
{
  issue3326: {
    _self: {
      x: [
        ...and(〈1;x〉),
      ]
    }
    〈0;_self〉
    x: [
      1,
    ]
  }
}
