# Tests that an indirect reference through a hidden field to a dynamic index
# correctly propagates an "incomplete" error rather than a misleading "cycle"
# error. Issue: indexing foo[_what] via a hidden variable _obj caused a "cycle
# error" instead of "invalid non-ground value" when _what was abstract.
# https://cuelang.org/issue/962
-- in.cue --
import "encoding/yaml"

foo: bar: "something"

text:  yaml.Marshal(_obj) @test(err, code=incomplete, pos=[2:8], contains="invalid non-ground value")

_what: string
_obj:  foo[_what] @test(err, code=incomplete, pos=[-1:8], contains="invalid non-ground value")
-- out/errors.txt --
[incomplete] _obj: invalid non-ground value string (must be concrete string):
    ./in.cue:7:8
[incomplete] _obj: invalid non-ground value string (must be concrete string):
    ./in.cue:7:8
-- out/eval/stats --
Leaks:  0
Freed:  6
Reused: 0
Allocs: 6
Retain: 0

Unifications: 6
Conjuncts:    6
Disjuncts:    0
