# Tests that hidden definitions (_#x) enforce closedness the same way regular
# definitions (#x) do, rejecting extra fields not declared in the definition.
# https://cuelang.org/issue/533
-- in.cue --
package x

#x: {
	Name: string
}

_#x: {
	Name: string
}

x1: #x & {
	Name: "hello"
	Age:  50
} @test(err, code=eval, at=Age, contains="field not allowed", pos=[2:2])

x2: _#x & {
	Name: "hello"
	Age:  50
} @test(err, code=eval, at=Age, contains="field not allowed", pos=[2:2])
-- out/errors.txt --
[eval] x1.Age: field not allowed:
    ./in.cue:13:2
[eval] x2.Age: field not allowed:
    ./in.cue:18:2
-- out/eval/stats --
Leaks:  0
Freed:  11
Reused: 4
Allocs: 7
Retain: 0

Unifications: 11
Conjuncts:    17
Disjuncts:    0

NumCloseIDs: 2
-- out/diff-v2-v3.txt --
Positions: v3 reports fewer positions than v2 for the "field not allowed" errors.
Verdict: worsening -- v3 reports fewer error positions than v2.
