internal/core/export: fix hidden field visibility for anonymous pkgID
When exporting a vertex with an empty pkgID (e.g. from a sub-value
looked up via LookupPath when the root has no associated instance),
hidden fields were silently suppressed even with ShowHidden=true.
The root cause: anonymous-package hidden labels store "_" as their pkgID
(the anonymous package marker), but the exporter's e.pkgID was "" when
no build.Instance is available. The comparison label.PkgID(ctx) ==
e.pkgID evaluated "_" == "" = false, so no hidden fields were emitted.
Fix: in structComposite, treat e.pkgID=="" as "_" before the comparison,
so anonymous exporters can see anonymous labels.
Also fix internal/cuetxtar inline.go to pass cue.Definitions(true) and
cue.Hidden(true) to formatValue, so that @test(eq, ...) directives on
fields with hidden or definition sub-fields produce correct expected
values. This is what triggered the discovery of the value.go bug.
Convert cue/testdata/scalars/yield.txtar to inline @test format.
Add regression tests in cue/syntax_test.go exercising the sub-value +
Final export path that triggered the bug.
Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I93ca352da3866c24643d7a07a466cbe4255fd75d
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1235231
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>