internal/core/adt: eagerly update kind to StructKind when aStruct is set
Previously, when a nodeContext had aStruct set (indicating it contains
struct members), the kind field might still be "top" during mid-evaluation.
This required a workaround in isEqualNodeValue to manually check aStruct
and mask the kind to StructKind for comparison.
This change updates the kind field to StructKind immediately when aStruct
is set, making the kind field accurate throughout evaluation. This allows
removal of the TODO workaround in isEqualNodeValue.
There are a number of test changes. First, the more precise kinds
cause some conflict errors to reorder their arguments.
Second, this reordering causes some more errors to be deduplicated,
as now the kind mid-evaluation is more likely to align
with the kind once a value is fully evaluated.
Third, some conflicting values errors are now much shorter,
as they are now based on the kind that we figure out upfront
rather than the full value that we would previously evaluate.
For example, from the encoding/jsonschema tests, we'd previously get:
conflicting values "a string to match #/$defs/id_in_enum" and {$id!:"https://localhost:1234/draft2020-12/id/my_identifier.json",type!:"null"} (mismatched types string and struct):
instance.json:1:1
conflicting values "a string to match #/$defs/id_in_enum" and {...} (mismatched types string and struct):
instance.json:1:1
invalid value "a string to match #/$defs/id_in_enum" (does not satisfy matchN): 0 matched, expected >=1:
instance.json:1:1
and now we omit the first error, which is redundant:
conflicting values "a string to match #/$defs/id_in_enum" and {...} (mismatched types string and struct):
instance.json:1:1
invalid value "a string to match #/$defs/id_in_enum" (does not satisfy matchN): 0 matched, expected >=1:
instance.json:1:1
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Ifd693ee8edb4413cb582449697ea103b8a191bd5
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1227404
Reviewed-by: Marcel van Lohuizen <mpvl@gmail.com>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>