# Tests that a definition used as a list element type correctly propagates default
# values and does not incorrectly reject fields like Pattern when unified.
# https://cuelang.org/issue/491
-- in.cue --
package x

#Prestep: {
	Args: *null | _
}

#PrestepNewUser: #Prestep & {
	Args: #NewUser
}

#NewUser: {
	Repos: [...#Repo]
}

#Repo: {
	Var:     string
	Pattern: *"*" | string
}

x: [...#Repo]
x: [{
	Var: "REPO1"
}]  @test(eq, [{Var: "REPO1", Pattern: *"*" | string}])

y: #Repo & {
	Var: "REPO1"
} @test(eq, {Var: "REPO1", Pattern: *"*" | string})

z: #PrestepNewUser & {
	Args: {
		Repos: [{
			Var: "REPO1"
		}]
	}
} @test(eq, {Args: {Repos: [{Var: "REPO1", Pattern: *"*" | string}]}})
-- out/eval/stats --
Leaks:  9
Freed:  33
Reused: 23
Allocs: 19
Retain: 0

Unifications: 24
Conjuncts:    60
Disjuncts:    14

NumCloseIDs: 8
