Changes which may break some users are marked below with: ⚠️
Evaluator
aliasv2
experiment
⚠️ The self
experiment introduced in v0.15.0-alpha.2 has been renamed to aliasv2
, to fully implement the Postfix Aliases proposal on GitHub.
Adding a new experiment like @experiment(postfixalias)
alongside @experiment(self)
was not a good option given that cue fix
can only adjust existing code correctly when both experiments are enabled. Allowing the use of just one half of the experiment would add too many tricky edge cases.
Once a module's language.version
targets v0.15.0
, this can be enabled via the file attribute @experiment(aliasv2)
. You can use cue fix --exp=aliasv2
to transition existing CUE code in a module to the new alias syntax and semantics.
Other changes
Fix a bug where required fields in a definition might not be enforced when unifying with an inline struct in an expression, such as (#RequiresFoo & {bar: "baz"}).bar
.
Fix a bug where a value's reference to self through a let
declaration would hang the evaluator.
Add caching to a part of the typochecker algorithm; this has been measured to provide speed-ups of up to 30% on a few large projects.
cmd/cue
cue mod mirror
now copies OCI referrers between registries, which ensures that artifacts like signatures and attestations which reference modules being mirrored are copied as well.
cue get go
gains an --outfile
flag to generate exactly one CUE file for a single Go package, which can be useful when integrating cue get go
into build systems like Bazel.
Encodings
Initial support for encoding CUE schemas as JSON Schema is added. This includes a new encoding/jsonschema.Generate Go API, as well as CLI support via cue def --out jsonschema
. This is very experimental as yet, and many features are missing. For now, it can only generate a single version of JSON Schema (draft/2020-12).
The YAML encoder no longer uses CUE's dependency analysis algorithm. This helps prevent panics that some users had run into with cue export -e expr --out yaml
.
Go API
The new cue.Value.IsClosed and cue.Value.IsClosedRecursively methods report whether a value has been closed at the top level or recursively, which is useful information when writing schema encodings.
The new cue.Patterns and cue.Selector.Pattern APIs allow introspecting pattern constraints in CUE struct values.
Full list of changes since v0.15.0-alpha.2
- all: rename aliasandself experiment to aliasv2 by @mpvl in b85644f
- encoding/jsonschema: explicit close handling by @rogpeppe in a94cfbc
- encoding/jsonschema: add tests by @rogpeppe in 2606457
- internal/ci: don't let "---" lines break git commit trailers by @mvdan in e735c99
- mod/modregistry: mirror referrers in Client.Mirror by @rogpeppe in f0d24a9
- all: go fix -slicescontains ./... by @mvdan in 7b65843
- all: go fix -stringsseq ./... by @mvdan in 2895806
- internal/core/adt: treat equality bound as open validator by @mpvl in 15f2a53
- internal/core/adt: add tests for Issue 4142 by @mpvl in de886bc
- cue/testdata/eval/bounds.txtar: accept v3 as golden by @mpvl in ff6f38b
- cue: support ... operator in Expr by @mpvl in 3d8e9ea
- internal/ci: bump Go and goreleaser by @mvdan in 64a5e68
- update all dependencies by @mvdan in d4d62e6
- tools/fix: add fixAliasAndSelf by @mpvl in 2b281ea
- internal/core: make label references work for all field types by @mpvl in 23a328a
- cue/ast/astutil: add resolver support for postfix aliases by @mpvl in 4d8b1da
- internal/core/adt: report error for missing required fields by @mpvl in a25fb94
- internal/core/adt: add tests for issue 3918 by @mpvl in 166a851
- cue/parser|format: implement postfix alias syntax by @mpvl in 0eb7de7
- all: apply more gopls suggestions by @mvdan in 8d2909c
- lsp/definitions: fix broken build due to self renaming by @cuematthew in 8df341b
- internal/cueexperiment: rename self experiment to aliasandself by @mpvl in a8dce0b
- internal/ci: use unauthenticated GerritHub URL by @jpluscplusm in 3dabab4
- cue: add postfix alias syntax infrastructure by @mpvl in d92ce18
- internal/core/adt: fix disjunction related mem mgmt bug by @mpvl in 335e4fb
- encoding/jsonschema: optimize items in definitions too by @rogpeppe in 098b6d1
- encoding/jsonschema: add a test to check optimization in definitions by @rogpeppe in 29ad8ee
- all: fix a number of bad godocs spotted by gopls by @mvdan in 5b42b38
- encoding: fix two gopls warnings by @mvdan in 33621a6
- switch this repository to cue.gerrithub.io by @mvdan in 2a81d1e
- encoding/jsonschema: use unique item values in Generate by @rogpeppe in 947c85c
- internal/anyunique: new package by @rogpeppe in 84c673a
- encoding/jsonschema: recognize pattern constraints in Generate by @rogpeppe in c356c10
- encoding/jsonschema: fix patternProperties in Extract by @rogpeppe in fc58592
- encoding/jsonschema: recognize different forms of "const" by @rogpeppe in 5433cb9
- cue: support iteration over pattern constraints by @rogpeppe in a6f97a1
- internal/core/adt: cache containsDefID results by @mvdan in 992c1cd
- internal/core/adt: always print errors in leaf nodes by @mpvl in 8dce6dc
- internal/ci: stop generating checksums.txt as a release archive by @mvdan in 15e67c0
- internal/core/adt: turn Vertex.VisitAllConjuncts into an iterator by @mvdan in 2536d4f
- internal/core/...: fully transition away from Vertex.VisitLeafConjuncts by @mvdan in 40aa589
- encoding/jsonschema: recognize closed structs in Generate by @rogpeppe in 113d7b9
- cue: implement IsClosed and IsClosedRecursively by @mpvl in b28a5f3
- encoding/jsonschema: improve teststats by @rogpeppe in 28054b0
- encoding/jsonschema: treat close as no-op for now by @rogpeppe in b670102
- encoding/jsonschema: recognize list.MatchN in Generate by @rogpeppe in 09a0f42
- encoding/jsonschema: recognize explicit errors in CUE by @rogpeppe in d293a17
- encoding/jsonschema: use error builtin rather than
_|_
by @rogpeppe in 49126bb
- cue: add test case for the fixed bug 4037 by @mvdan in 5c6dd1c
- cue: fix panic in LookupPath on unfinalized arcs by @rogpeppe in 4160e88
- encoding/jsonschema: recognize matchIf in Generate by @rogpeppe in fedcd87
- internal/core/adt: avoid hang on self-references through "let" by @mvdan in 85e008d
- encoding/yaml: consistently use cue.Concrete when calling Value.Syntax by @mvdan in 39d559b
- encoding/jsonschema: use more generic
siblings
function by @rogpeppe in 366de4b
- encoding/jsonschema: minor improvements to Generate by @rogpeppe in 06d8b91
- encoding/jsonschema: add a few tests by @rogpeppe in 2efaae1
- encoding/jsonschema: recognize matchN in Generate by @rogpeppe in 40a9710
- encoding/jsonschema: round trip external tests by @rogpeppe in 899a983
- encoding/jsonschema: list support by @rogpeppe in b4b3d1b
- encoding/jsonschema: improve mergeAllOf behavior by @rogpeppe in b8e3859
- internal/core/adt: test TopKind in TestKindString by @mvdan in 42731c2
- all: continue transition away from adt.Vertex.VisitLeafConjuncts by @mvdan in 658608c
- encoding/jsonschema: adjust for net/url fix in go@master by @mvdan in f79aafe
- internal/core/adt: add the Vertex.LeafConjuncts iterator by @mvdan in 2af8a20
- internal/core/adt: turn VisitConjuncts into ConjunctsSeq by @mvdan in b33320b
- internal/mod/semver: clean up with cmp.Compare by @mvdan in a85df20
- cmd/cue: clarify what version affects experiments by @mvdan in ef2044e
- cmd/cue: add --outfile flag to
get go
by @fionera in a6eaaf6
- encoding/jsonschema: use ast.Expr rather than map by @rogpeppe in 77c93c6
- encoding/jsonschema: add test case for regular fields by @rogpeppe in e58947e
- internal/encoding: add jsonschema as an output format by @rogpeppe in 577c245
- internal/encoding: do not require input to be concrete for concrete output formats by @rogpeppe in 9305978
- internal/encoding: refactor Encoder.Encode, Encoder.EncodeFile by @rogpeppe in 93c27cc
- cmd/cue: explain package instances in cue-help-inputs by @jpluscplusm in 103b1ce
- cmd/cue: rewrite export help text by @jpluscplusm in ff5711d
- internal/cuetxtar: do not skip tests on Instance failure by @rogpeppe in d62b617
- Revert "mod/modregistry: mirror referrers in Client.Mirror" by @mvdan in 6f47bbf
- mod/modregistry: mirror referrers in Client.Mirror by @rogpeppe in 9b06b4c
- encoding/jsonschema: implement Generate by @rogpeppe in c60b98a
- cue/ast: simplify IsValidIdent logic via strings.CutPrefix by @mvdan in 53ace20
- cue: reuse internal.IsDef to tell if a name is a definition by @mvdan in c486bc3
- encoding/jsonschema: remove unused state.value method by @mvdan in 14a7236
- cue/literal: properly include hashes in escape sequences in bytes by @mvdan in d21fac3
- cue/literal: add test case for lossy bytes quoting by @mvdan in d8c663c