internal/core/adt: fix spurious error in ForClause.yield key binding
When iterating over a struct with an error (e.g., missing required field),
the OpContext would have an error set. The old code used Feature.ToValue
which called ctx.NewString/ctx.NewInt64, and these methods return the
context's error when c.HasErr() is true instead of creating the value.
This caused a spurious cascading error like "key value of dynamic field
must be concrete" even though the key label itself was valid - only the
iterated value had an error.
Fix this by constructing String and Num values directly, bypassing the
error-checking in NewString/NewInt64. The key is always derived from a
valid label, so it should not inherit unrelated errors from the context.
This resolves a todo/p2 in cue/testdata/comprehensions/fields.txtar.
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I31c23a193ea67f22ae0c0b5bac14014494f9984a
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1229649
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Matthew Sackman <matthew@cue.works>