-- issue3750.cue --
package p

import "list"

issue3750: original: {
	out: #Foo & {
		sub: #Foo
	}

	#Foo: {
		sub: #Foo | #Bar
		meta: {
			strs: [...string]
			for _, w in list.FlattenN([strs], 1) {}
		}
	}


	#Bar: {
		kind: "bar"
		meta: strs: [...string]
	}
}

issue3750: reduced: {
	out: Foo & { sub: Foo }

	Foo: {
		sub: Foo | {a: b: _}
		a: {
			b: _
			for _, w in list.FlattenN([b], 1) {}
		}
	}
}
-- issue3780.cue --
import "strings"

issue3780: panic1: {
	objs: #Objects & {}
	param!: bool
	if param {
		objs: obj1: {
			one: 1
			two: 2
		}
	}
	#Objects: [strings.HasPrefix("obj")]: {
		kind: "object"
		...
	}
}
issue3780: panic2: {
	parent: {
		objs: #Objects & {}
		param?: bool
		if param != _|_ {
			objs: obj1: {
				one: 1
				two: 2
			}
		}
		#Objects: [strings.HasPrefix("obj")]: {
			kind: "object"
			...
		}
	}
}
-- issue3770.cue --
issue3770: task: {
	m: {
		let t = ["x"]
		for m in t {
			(m): a: 1
		}
		x: b: 1
	}
	m: null | {  }
	out: m.x.a
}
-- issue3824.cue --
issue3824: panic: {
	thing: {
        spec: name: string
        outputField: string
	}

	val: string
	things: [_]: thing

	things: [_]: {
			spec: *{
					name: "self-signed"
			} | {...}
	}

	if true {
			things: "name": {}
			val: things["name"].outputField
	}
}
-- out/compile --
--- issue3750.cue
{
  issue3750: {
    original: {
      out: (〈0;#Foo〉 & {
        sub: 〈1;#Foo〉
      })
      #Foo: {
        sub: (〈1;#Foo〉|〈1;#Bar〉)
        meta: {
          strs: [
            ...string,
          ]
          for _, w in 〈import;list〉.FlattenN([
            〈1;strs〉,
          ], 1) {}
        }
      }
      #Bar: {
        kind: "bar"
        meta: {
          strs: [
            ...string,
          ]
        }
      }
    }
  }
  issue3750: {
    reduced: {
      out: (〈0;Foo〉 & {
        sub: 〈1;Foo〉
      })
      Foo: {
        sub: (〈1;Foo〉|{
          a: {
            b: _
          }
        })
        a: {
          b: _
          for _, w in 〈import;list〉.FlattenN([
            〈1;b〉,
          ], 1) {}
        }
      }
    }
  }
}
--- issue3770.cue
{
  issue3770: {
    task: {
      m: {
        let t#1 = [
          "x",
        ]
        for _, m in 〈0;let t#1〉 {
          〈1;m〉: {
            a: 1
          }
        }
        x: {
          b: 1
        }
      }
      m: (null|{})
      out: 〈0;m〉.x.a
    }
  }
}
--- issue3780.cue
{
  issue3780: {
    panic1: {
      objs: (〈0;#Objects〉 & {})
      param!: bool
      if 〈0;param〉 {
        objs: {
          obj1: {
            one: 1
            two: 2
          }
        }
      }
      #Objects: {
        [〈import;strings〉.HasPrefix("obj")]: {
          kind: "object"
          ...
        }
      }
    }
  }
  issue3780: {
    panic2: {
      parent: {
        objs: (〈0;#Objects〉 & {})
        param?: bool
        if (〈0;param〉 != _|_(explicit error (_|_ literal) in source)) {
          objs: {
            obj1: {
              one: 1
              two: 2
            }
          }
        }
        #Objects: {
          [〈import;strings〉.HasPrefix("obj")]: {
            kind: "object"
            ...
          }
        }
      }
    }
  }
}
--- issue3824.cue
{
  issue3824: {
    panic: {
      thing: {
        spec: {
          name: string
        }
        outputField: string
      }
      val: string
      things: {
        [_]: 〈1;thing〉
      }
      things: {
        [_]: {
          spec: (*{
            name: "self-signed"
          }|{
            ...
          })
        }
      }
      if true {
        things: {
          name: {}
        }
        val: 〈0;things〉["name"].outputField
      }
    }
  }
}
-- out/evalalpha/stats --
Leaks:  259
Freed:  0
Reused: 0
Allocs: 259
Retain: 0

Unifications: 197
Conjuncts:    309
Disjuncts:    38

CloseIDElems: 508
NumCloseIDs: 43
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
diff old new
--- old
+++ new
@@ -1,9 +1,12 @@
-Leaks:  1
-Freed:  165
-Reused: 153
-Allocs: 13
-Retain: 38
-
-Unifications: 138
-Conjuncts:    254
-Disjuncts:    204
+Leaks:  259
+Freed:  0
+Reused: 0
+Allocs: 259
+Retain: 0
+
+Unifications: 197
+Conjuncts:    309
+Disjuncts:    38
+
+CloseIDElems: 508
+NumCloseIDs: 43
-- out/eval/stats --
Leaks:  1
Freed:  165
Reused: 153
Allocs: 13
Retain: 38

Unifications: 138
Conjuncts:    254
Disjuncts:    204
-- out/evalalpha --
(struct){
  issue3750: (struct){
    original: (struct){
      out: (#struct){
        sub: (#struct){
          sub: (#struct){ |((#struct){
              sub: (#struct){ |((#struct){
                  sub: (#struct){
                    kind: (string){ "bar" }
                    meta: (#struct){
                      strs: (list){
                      }
                    }
                  }
                  meta: (#struct){
                    strs: (list){
                    }
                  }
                }, (#struct){
                  kind: (string){ "bar" }
                  meta: (#struct){
                    strs: (list){
                    }
                  }
                }) }
              meta: (#struct){
                strs: (list){
                }
              }
            }, (#struct){
              kind: (string){ "bar" }
              meta: (#struct){
                strs: (list){
                }
              }
            }) }
          meta: (#struct){
            strs: (list){
            }
          }
        }
        meta: (#struct){
          strs: (list){
          }
        }
      }
      #Foo: (#struct){
        sub: (#struct){
          kind: (string){ "bar" }
          meta: (#struct){
            strs: (list){
            }
          }
        }
        meta: (#struct){
          strs: (list){
          }
        }
      }
      #Bar: (#struct){
        kind: (string){ "bar" }
        meta: (#struct){
          strs: (list){
          }
        }
      }
    }
    reduced: (struct){
      out: (struct){
        sub: (struct){
          sub: (struct){ |((struct){
              sub: (struct){ |((struct){
                  sub: (struct){
                    a: (struct){
                      b: (_){ _ }
                    }
                  }
                  a: (struct){
                    b: (_){ _ }
                  }
                }, (struct){
                  a: (struct){
                    b: (_){ _ }
                  }
                }) }
              a: (struct){
                b: (_){ _ }
              }
            }, (struct){
              a: (struct){
                b: (_){ _ }
              }
            }) }
          a: (struct){
            b: (_){ _ }
          }
        }
        a: (struct){
          b: (_){ _ }
        }
      }
      Foo: (struct){
        sub: (struct){
          a: (struct){
            b: (_){ _ }
          }
        }
        a: (struct){
          b: (_){ _ }
        }
      }
    }
  }
  issue3770: (struct){
    task: (struct){
      m: (struct){
        let t#1 = (#list){
          0: (string){ "x" }
        }
        x: (struct){
          b: (int){ 1 }
          a: (int){ 1 }
        }
      }
      out: (int){ 1 }
    }
  }
  issue3780: (struct){
    panic1: (_|_){
      // [incomplete] issue3780.panic1: incomplete bool: bool:
      //     ./issue3780.cue:5:10
      objs: (#struct){
      }
      param!: (bool){ bool }
      #Objects: (#struct){
      }
    }
    panic2: (struct){
      parent: (struct){
        objs: (#struct){
        }
        param?: (bool){ bool }
        #Objects: (#struct){
        }
      }
    }
  }
  issue3824: (struct){
    panic: (struct){
      thing: (struct){
        spec: (struct){
          name: (string){ string }
        }
        outputField: (string){ string }
      }
      val: (string){ string }
      things: (struct){
        name: (struct){
          spec: (struct){ |(*(struct){
              name: (string){ "self-signed" }
            }, (struct){
              name: (string){ string }
            }) }
          outputField: (string){ string }
        }
      }
    }
  }
}
-- diff/-out/evalalpha<==>+out/eval --
diff old new
--- old
+++ new
@@ -3,13 +3,37 @@
     original: (struct){
       out: (#struct){
         sub: (#struct){
-          sub: (#struct){
-            kind: (string){ "bar" }
-            meta: (#struct){
-              strs: (list){
-              }
-            }
-          }
+          sub: (#struct){ |((#struct){
+              sub: (#struct){ |((#struct){
+                  sub: (#struct){
+                    kind: (string){ "bar" }
+                    meta: (#struct){
+                      strs: (list){
+                      }
+                    }
+                  }
+                  meta: (#struct){
+                    strs: (list){
+                    }
+                  }
+                }, (#struct){
+                  kind: (string){ "bar" }
+                  meta: (#struct){
+                    strs: (list){
+                    }
+                  }
+                }) }
+              meta: (#struct){
+                strs: (list){
+                }
+              }
+            }, (#struct){
+              kind: (string){ "bar" }
+              meta: (#struct){
+                strs: (list){
+                }
+              }
+            }) }
           meta: (#struct){
             strs: (list){
             }
@@ -43,34 +67,34 @@
     }
     reduced: (struct){
       out: (struct){
-        sub: (struct){ |((struct){
-            sub: (struct){ |((struct){
-                a: (struct){
-                  b: (_){ _ }
-                }
-                sub: (struct){
-                  a: (struct){
-                    b: (_){ _ }
-                  }
-                }
-              }, (struct){
-                a: (struct){
-                  b: (_){ _ }
-                }
-              }) }
-            a: (struct){
-              b: (_){ _ }
-            }
-          }, (struct){
-            sub: (struct){
-              a: (struct){
-                b: (_){ _ }
-              }
-            }
-            a: (struct){
-              b: (_){ _ }
-            }
-          }) }
+        sub: (struct){
+          sub: (struct){ |((struct){
+              sub: (struct){ |((struct){
+                  sub: (struct){
+                    a: (struct){
+                      b: (_){ _ }
+                    }
+                  }
+                  a: (struct){
+                    b: (_){ _ }
+                  }
+                }, (struct){
+                  a: (struct){
+                    b: (_){ _ }
+                  }
+                }) }
+              a: (struct){
+                b: (_){ _ }
+              }
+            }, (struct){
+              a: (struct){
+                b: (_){ _ }
+              }
+            }) }
+          a: (struct){
+            b: (_){ _ }
+          }
+        }
         a: (struct){
           b: (_){ _ }
         }
-- out/eval --
(struct){
  issue3750: (struct){
    original: (struct){
      out: (#struct){
        sub: (#struct){
          sub: (#struct){
            kind: (string){ "bar" }
            meta: (#struct){
              strs: (list){
              }
            }
          }
          meta: (#struct){
            strs: (list){
            }
          }
        }
        meta: (#struct){
          strs: (list){
          }
        }
      }
      #Foo: (#struct){
        sub: (#struct){
          kind: (string){ "bar" }
          meta: (#struct){
            strs: (list){
            }
          }
        }
        meta: (#struct){
          strs: (list){
          }
        }
      }
      #Bar: (#struct){
        kind: (string){ "bar" }
        meta: (#struct){
          strs: (list){
          }
        }
      }
    }
    reduced: (struct){
      out: (struct){
        sub: (struct){ |((struct){
            sub: (struct){ |((struct){
                a: (struct){
                  b: (_){ _ }
                }
                sub: (struct){
                  a: (struct){
                    b: (_){ _ }
                  }
                }
              }, (struct){
                a: (struct){
                  b: (_){ _ }
                }
              }) }
            a: (struct){
              b: (_){ _ }
            }
          }, (struct){
            sub: (struct){
              a: (struct){
                b: (_){ _ }
              }
            }
            a: (struct){
              b: (_){ _ }
            }
          }) }
        a: (struct){
          b: (_){ _ }
        }
      }
      Foo: (struct){
        sub: (struct){
          a: (struct){
            b: (_){ _ }
          }
        }
        a: (struct){
          b: (_){ _ }
        }
      }
    }
  }
  issue3770: (struct){
    task: (struct){
      m: (struct){
        let t#1 = (#list){
          0: (string){ "x" }
        }
        x: (struct){
          b: (int){ 1 }
          a: (int){ 1 }
        }
      }
      out: (int){ 1 }
    }
  }
  issue3780: (struct){
    panic1: (_|_){
      // [incomplete] issue3780.panic1: incomplete bool: bool:
      //     ./issue3780.cue:5:10
      objs: (#struct){
      }
      param!: (bool){ bool }
      #Objects: (#struct){
      }
    }
    panic2: (struct){
      parent: (struct){
        objs: (#struct){
        }
        param?: (bool){ bool }
        #Objects: (#struct){
        }
      }
    }
  }
  issue3824: (struct){
    panic: (struct){
      thing: (struct){
        spec: (struct){
          name: (string){ string }
        }
        outputField: (string){ string }
      }
      val: (string){ string }
      things: (struct){
        name: (struct){
          spec: (struct){ |(*(struct){
              name: (string){ "self-signed" }
            }, (struct){
              name: (string){ string }
            }) }
          outputField: (string){ string }
        }
      }
    }
  }
}
