
# Tests that "field not allowed" errors in closed structs include sufficient
# diagnostic information about the source of the restriction.
# https://cuelang.org/issue/320
-- in.cue --
#Foo: {
	x: string
	#More
}

#More: [=~"^x-"]: _

foo: #Foo & {
	x: "hello"
	y: "goodbye"
} @test(err, at=y, code=eval,
	hint="could use more positions, like in v2",
	contains="field not allowed",
	pos=[in.cue:10:2])
-- out/errors.txt --
[eval] foo.y: field not allowed:
    ./in.cue:10:2
-- out/eval/stats --
Leaks:  0
Freed:  7
Reused: 1
Allocs: 6
Retain: 0
Unifications: 7
Conjuncts:    14
Disjuncts:    0
NumCloseIDs: 7
-- out/diff-v2-v3.txt --
Positions: v3 reports fewer positions than v2 for the "field not allowed" error.
Verdict: worsening -- v3 reports fewer error positions than v2.
foo.y: field not allowed:
-    ./in.cue:1:7
-    ./in.cue:3:2
-    ./in.cue:6:8
-    ./in.cue:8:6
     ./in.cue:10:2
