# Tests that close() correctly rejects fields not present in the closed struct
# when the closed value is later unified with an open struct adding new fields.
# https://cuelang.org/issue/490
-- test.cue --
A: close({
	a: 1
	b: 2
}) @test(eq, {a: 1, b: 2})

B: A & {
	c: 3
} @test(err, code=eval, at=c, contains="field not allowed", pos=[1:2])

@test(debugCheck, """
	(_|_){
	  // [eval]
	  A: (#struct){
	    a: (int){ 1 }
	    b: (int){ 2 }
	  }
	  B: (_|_){
	    // [eval]
	    c: (_|_){
	      // [eval] B.c: field not allowed:
	      //     test.cue:7:2
	    }
	    a: (int){ 1 }
	    b: (int){ 2 }
	  }
	}
	""")
-- out/eval/stats --
Leaks:  0
Freed:  20
Reused: 8
Allocs: 12
Retain: 0

Unifications: 12
Conjuncts:    16
Disjuncts:    0

NumCloseIDs: 3
-- out/errors.txt --
[eval] B.c: field not allowed:
    ./test.cue:7:2
-- out/diff-v2-v3.txt --
positions
Reordering
Verdict: worsening -- v3 reports different error positions; field reordering.
