-- references.cue --
missingField: {
	a: {}
	r: a.b @test(err, code=incomplete, contains="undefined field: b", pos=[0:7])
}

missingFieldClosed: {
	#a: {}
	r: #a.b @test(err, code=eval, contains="undefined field: b", pos=[0:8])
}

missingFieldNested: {
	a: {}
	// Must refer to `b` in error
	r: a.b.c @test(err, code=incomplete, contains="undefined field: b", pos=[0:7])
}

missingFieldNestedClosed: {
	#a: {}

	// Must refer to `d` in error
	r: #a.d.c @test(err, code=eval, contains="undefined field: d", pos=[0:8])
}

missingFieldNestedInInterpolation: {
	a: {}
	// Must refer to `b` in error
	r1: "\(a.b.c)" @test(err, code=incomplete, contains="invalid interpolation: undefined field: b", pos=[0:6, 0:11])
	// Must refer to `d` in error: in case only one error is shown for a
	// a location, ensure it doesn't alphabetically sort and pick `c` instead.
	r2: "\(a.d.c)" @test(err, code=incomplete, contains="invalid interpolation: undefined field: d", pos=[0:6, 0:11])
}
-- out/errors.txt --
[incomplete] missingField.r: undefined field: b:
    ./references.cue:3:7
[eval] missingFieldClosed.r: undefined field: b:
    ./references.cue:8:8
[incomplete] missingFieldNested.r: undefined field: b:
    ./references.cue:14:7
[eval] missingFieldNestedClosed.r: undefined field: d:
    ./references.cue:21:8
[incomplete] missingFieldNestedInInterpolation.r1: invalid interpolation: undefined field: b:
    ./references.cue:27:6
    ./references.cue:27:11
[incomplete] missingFieldNestedInInterpolation.r2: invalid interpolation: undefined field: d:
    ./references.cue:30:6
    ./references.cue:30:11
-- out/eval/stats --
Leaks:  0
Freed:  17
Reused: 8
Allocs: 9
Retain: 0

Unifications: 17
Conjuncts:    17
Disjuncts:    0
