# 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)

_what: string
_obj:  foo[_what]
-- out/compile --
--- in.cue
{
  foo: {
    bar: "something"
  }
  text: 〈import;"encoding/yaml"〉.Marshal(〈0;_obj〉)
  _what: string
  _obj: 〈0;foo〉[〈0;_what〉]
}
