
# Allow otherField
# Tests that comprehension-based schemas and deployment configurations correctly
# allow fields defined through pattern constraints and let comprehensions.
# Issue: https://cuelang.org/issue/317
-- in.cue --
#T: {
	#Schema: [_]: #D
	concrete: #Schema
}
#D: {
	fieldWithDefault: *0 | int
	...
}
s: #T & {
	#Schema: {
		foo: otherField: string
	}
	concrete: foo: otherField: "hello"
}
#Container: {
	Env: [Name=string]: {
		name:  string
		value: string
	}
}
#Deployment: {
	#Containers: [Name=string]: #Container
	containers: [for c in #Containers {c}] // Problem is here.
}
Something: {
	#Deployment
	#Containers: {
		// Does not allow entries other than value. Either add ... or embed
		"a thing": Env: foobar: value: "foo"
	}
}
x: Something & #Deployment
-- out/compile --
--- in.cue
{
  #T: {
    #Schema: {
      [_]: 〈2;#D〉
    }
    concrete: 〈0;#Schema〉
  }
  #D: {
    fieldWithDefault: (*0|int)
    ...
  }
  s: (〈0;#T〉 & {
    #Schema: {
      foo: {
        otherField: string
      }
    }
    concrete: {
      foo: {
        otherField: "hello"
      }
    }
  })
  #Container: {
    Env: {
      [string]: {
        name: string
        value: string
      }
    }
  }
  #Deployment: {
    #Containers: {
      [string]: 〈2;#Container〉
    }
    containers: [
      for _, c in 〈1;#Containers〉 {
        〈1;c〉
      },
    ]
  }
  Something: {
    〈1;#Deployment〉
    #Containers: {
      "a thing": {
        Env: {
          foobar: {
            value: "foo"
          }
        }
      }
    }
  }
  x: (〈0;Something〉 & 〈0;#Deployment〉)
}
