encoding/jsonschema: handle items keyword correctly in draft2020-12
In JSON Schema draft2020-12, when prefixItems is present, the items
keyword behaves like additionalItems from older drafts: it constrains
only elements beyond the prefix, not all elements.
Previously, constraintItems always created [...elem] which applied to
all items. With items: false and prefixItems, this incorrectly
disallowed even the prefix items themselves.
Fix this by:
- Moving prefixItems to phase 1 so it is always processed before
items (phase 2).
- In constraintItems, when s.list is already set (by prefixItems),
modifying the existing list's ellipsis via a shared
setAdditionalItems helper instead of creating a new constraint.
Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I9ff46e282c7bfc00a38c0430340732c008f83f21
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1232503
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>