-- in.cue --
#simple: {
	peso: *1 | int
	edad: *2 | int
}

// Second struct is not considered closed, as expected
good: #simple & {
	peso: 4
}

#complex: {
	things: [string]: #simple
}

// Still, no closedness issue in the second struct
#many: #complex & {
	things: hola: peso: 2
	things: sol: peso:  3
}

// Inner struct in second struct IS considered closed: why?
bad: #many & {
	things: hola: peso: 2
}

// non-definition equivalent
many: #complex & {
	things: hola: peso: 2
	things: sol: peso:  3
}

// Now inner struct on second struct is NOT considered closed
notbad: many & {
	things: hola: peso: 2
}
-- out/eval/stats --
Leaks:  0
Freed:  81
Reused: 74
Allocs: 7
Retain: 0

Unifications: 41
Conjuncts:    134
Disjuncts:    81
-- out/eval --
(struct){
  #simple: (#struct){
    peso: (int){ |(*(int){ 1 }, (int){ int }) }
    edad: (int){ |(*(int){ 2 }, (int){ int }) }
  }
  good: (#struct){
    peso: (int){ 4 }
    edad: (int){ |(*(int){ 2 }, (int){ int }) }
  }
  #complex: (#struct){
    things: (#struct){
    }
  }
  #many: (#struct){
    things: (#struct){
      hola: (#struct){
        peso: (int){ 2 }
        edad: (int){ |(*(int){ 2 }, (int){ int }) }
      }
      sol: (#struct){
        peso: (int){ 3 }
        edad: (int){ |(*(int){ 2 }, (int){ int }) }
      }
    }
  }
  bad: (#struct){
    things: (#struct){
      hola: (#struct){
        peso: (int){ 2 }
        edad: (int){ |(*(int){ 2 }, (int){ int }) }
      }
      sol: (#struct){
        peso: (int){ 3 }
        edad: (int){ |(*(int){ 2 }, (int){ int }) }
      }
    }
  }
  many: (#struct){
    things: (#struct){
      hola: (#struct){
        peso: (int){ 2 }
        edad: (int){ |(*(int){ 2 }, (int){ int }) }
      }
      sol: (#struct){
        peso: (int){ 3 }
        edad: (int){ |(*(int){ 2 }, (int){ int }) }
      }
    }
  }
  notbad: (#struct){
    things: (#struct){
      hola: (#struct){
        peso: (int){ 2 }
        edad: (int){ |(*(int){ 2 }, (int){ int }) }
      }
      sol: (#struct){
        peso: (int){ 3 }
        edad: (int){ |(*(int){ 2 }, (int){ int }) }
      }
    }
  }
}
-- out/compile --
--- in.cue
{
  #simple: {
    peso: (*1|int)
    edad: (*2|int)
  }
  good: (〈0;#simple〉 & {
    peso: 4
  })
  #complex: {
    things: {
      [string]: 〈2;#simple〉
    }
  }
  #many: (〈0;#complex〉 & {
    things: {
      hola: {
        peso: 2
      }
    }
    things: {
      sol: {
        peso: 3
      }
    }
  })
  bad: (〈0;#many〉 & {
    things: {
      hola: {
        peso: 2
      }
    }
  })
  many: (〈0;#complex〉 & {
    things: {
      hola: {
        peso: 2
      }
    }
    things: {
      sol: {
        peso: 3
      }
    }
  })
  notbad: (〈0;many〉 & {
    things: {
      hola: {
        peso: 2
      }
    }
  })
}
