cue/errors: avoid duplicate path in error list formatting
When list.Msg returned p[0] as a format argument for multi-error lists,
the error's path would appear twice: once from list.Path
(which delegates to p[0].Path) and again when the error was
formatted as a %s argument via errorFormatter.String(),
added in https://cuelang.org/cl/1222367 to enable cycle detection.
Fix this by wrapping p[0] in a pathlessError type that overrides Path
to return nil, suppressing the duplicate path prefix while
preserving the full error chain via Unwrap.
Fixes #4171
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I97366fd64d2bb2695b39135d89e10b48e2656a6a
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1231147
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Matthew Sackman <matthew@cue.works>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>