internal/cuetxtar: fix hidden-field path handling in source AST walker
Previously, extractTestAttrs called appendPath → cue.Label(ident) for
every AST field label. cue.Label returns a path-error selector for hidden
identifiers (_foo) with the message "use Hid to construct". As a result:
- The walkField/walkStruct recursion was silently skipped for any field
whose label is a hidden identifier, so @test annotations inside hidden
fields were never collected.
- applyShareIDAt used cue.ParsePath which likewise rejected hidden labels.
- at= in @test(err) and @test(eq) failed with "invalid path" when the
selector was a package-scoped hidden field like _foo$pkg.
Fixes:
- Add labelSelector(label, hidPkg) that creates cue.Hid(name, pkg) for
hidden idents. Source-file walkers pass hidPkg = ":" + f.PackageName()
(or "_" for anonymous files); eq-body walkers pass "" which triggers
$pkg-suffix parsing (same as astcmp.go).
- Rename appendPath to take the hidPkg argument and use labelSelector.
- extractTestAttrs now computes hidPkg from f.PackageName() and passes it
through walkField/walkStruct closures, so @test annotations on or inside
hidden fields are correctly collected and evaluated.
- parseAtPath (used by at= in @test(err) and @test(eq)) now splits on "."
and applies hidden-field handling to each segment, supporting paths like
a._foo$pkg.b.
- applyShareIDAt uses parseAtPath instead of cue.ParsePath.
Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: Ieef7cf72a94a59b269fb6f84dab6c8e2c443cff6
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1235355
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>