Releases: cue-lang/cue
v0.16.0-alpha.1
Changes which may break some users are marked below with:
Language
As a reminder, we have two ongoing language experiments since v0.15; a replacement for struct embedding and a rework of aliases. Please give these a try and report any issues or feedback!
cmdreferencepkg global experiment is now stable, meaning that CUE_EXPERIMENT=cmdreferencepkg is always enabled.
#"""# is now accepted as a string literal quoting a double quote, ".
Multiline string literals now require a trailing newline, matching the language spec.
Evaluator
Performance
Further improve the use of caching in the typochecker algorithm; this provides speed-ups of up to 80% on some large projects.
Very large structs (tested with 20,000 fields) are up to 80% faster now, as we were repeating some work unnecessarily.
A great deal of effort has gone into reducing the allocations and memory usage across a number of projects. For some of these, memory usage is down by as much as 60%.
These improvements were possible thanks to our Unity service, letting us analyze CUE's performance and test for regressions on third party projects. Contact @mvdan on Discord, Slack, or via the Unity page to ensure that your project is included or you are running into slowness.
Other changes
Fix a regression introduced in v0.13 where the or built-in with literal arguments could stop behaving like a disjunction.
A number of panics and other bugs in the evaluator which were reported since v0.15.0 have been fixed; thank you to all who reported these.
cmd/cue
Add support for $DOCKER_AUTH_CONFIG to directly provide the contents of $DOCKER_CONFIG/config.json to authenticate with module registries, matching Docker's current behavior.
The --outfile flag now works when given non-regular files such as named pipes or sockets.
cue mod publish no longer ignores sub-directories containing a go.mod file as if they were nested CUE modules; those are already skipped based on the presence of cue.mod.
cue inside the cue.mod directory now fails consistently with a clear error message to not place CUE code there. Previously, some commands worked while others failed with confusing errors.
LSP server
Completions: a complete overhaul of how the LSP server suggests code completions. This solves the previous naïve implementation which would only make suggestions after a field name or path had been started. Now completions are available from within whitespace.
Embedded paths with mutual dependencies: embedded paths with multiple components (e.g. a.b.c) can in some cases only be fully resolved after the resolution of other embedded paths. The LSP server can now correctly handle these dependencies.
Document Symbols: the CUE LSP server now implements LSP "Document Symbols" functionality. This is often used by editors to provide light-weight breadcrumb navigation within a file.
Diagnostics: some preliminary diagnostics are now sent from the LSP server back to the editor. Initially this mainly indicates syntax errors in CUE files, but this can be extended in the future.
Bug fixes: many smaller bug fixes, addressing issues around imports, path resolution, formatting of standalone CUE files, amongst others.
See our Getting Started wiki page for instructions on how to set it up with your editor.
Please report any bugs or missing features you encounter via the Issue tracker or via the #lsp channels on Discord or Slack.
Encodings
cue get go now detects which Go packages use Kubernetes type semantics via // +k8s:openapi-gen=true and obeys the field annotations // +optional and // +nullable.
cue get go gains a --codec flag to configure the use and priority of Go struct field tags like json or yaml.
Fix a bug where cue get go could skip over fields whose type implements one of the supported marshaling interfaces.
Fix a few bugs where cue get go could result in invalid or failing CUE code.
JSON Schema's Config.OpenOnlyWhenExplicit option is now exposed for the CLI via the filetype tag jsonschema+openOnlyWhenExplicit.
JSON Schema now properly encodes hash references for better compatibility with other tools.
Standard library
The strconv package adds ParseNumber, like ParseInt or ParseFloat but allowing other CUE number strings such as 1Ki.
The net package adds InCIDR to test whether an IP is contained by a CIDR string.
The net package adds ParseCIDR to extract useful information from a CIDR string.
Go API
cue.Value.Decode now supports the new cue.Unmarshaler interface, allowing Go types to implement their own CUE value decoding logic via an UnmarshalCUE(cue.Value) error method.
The new cue.IsIncomplete function reports whether the given value is a CUE incomplete error.
cue.Value.Decode now uses cue.IsIncomplete to not treat incomplete errors as fatal, allowing the decoding to continue.
Fix a bug where cue.Value.Decode could behave incorrectly when decoding a CUE null or incomplete value.
cue/ast.Node.Comments and cue/ast.Node.AddComment interface methods are now removed; use cue/ast.Comments and cue/ast.AddComment respectively.
cue/parser.FromVersion and cue/parser.DeprecationError APIs are now removed.
Full list of changes since v0.15.0
- cue/load: error when loading packages from inside cue.mod by @mvdan in 52e0dde
- cmd/cue: add a testscript running commands inside cue.mod by @mvdan in 50aaf7e
- mod/modzip: check for cue.mod existence, not just directories by @mvdan in 8034cc1
- mod/modzip: check for cue.mod directories instead of go.mod files by @mvdan in 8957a36
- mod/modzip: add test for go.mod submodule detection by @mvdan in 3be6c26
- cue/format: simplify label replacement without astutil.Apply by @mvdan in fdc3f74
- cmd/cue: clarify the restrictions around @embed file paths by @mvdan in dc9a189
- .claude: allow more commands by @mvdan in 60b5bd9
- pkg/net: add ParseCIDR to extract CIDR information by @mvdan in ea83954
- pkg/net: add InCIDR to check if an IP is within a CIDR range by @mvdan in a3cffd4
- cue/format: fix comma placement for ellipsis with inline comments by @mvdan in 79305ff
- cue/format: add test for issue #4238 by @mvdan in 452fbae
- internal/core/adt: fix spurious error in ForClause.yield key binding by @mvdan in beae55b
- CLAUDE: discourage "go build" and add a set of "must follow" rules by @mvdan in 6301c2a
- encoding/json: correct positions of field labels from json by @cuematthew in 8c70d8d
- internal/cueexperiment: clarify the docs and update the ordering by @mvdan in 46dc5d7
- cmd/cue: appease gopls in gen_experiments_help.go by @mvdan in 79c8f3a
- internal/ci: bump Go and goreleaser for v0.16.0-alpha.1 by @mvdan in 29a1c5a
- update dependencies ahead of v0.16.0-alpha.1 by @mvdan in 14cf3bd
- doc/ref: clarify the relationship between exported and hidden identifiers by @mvdan in 367bc88
- internal/core/adt: avoid allocations in matchPattern by @mvdan in 523284f
- internal/core/adt: remove redundant updateConjunctInfo call by @mvdan in e52024b
- internal/core/convert: allocate vertices in ensureArcVertex better by @mvdan in e2b85a8
- pkg/math/bits: avoid an extra allocation per call by @mvdan in 9adb47a
- internal/core/convert: reuse singleton struct and list marker allocs by @mvdan in d06db86
- internal/core/adt: remove unused parameters in Vertex.AddStruct by @mvdan in a8d5eef
- internal/core/convert: avoid repeated OpContext.Env calls by @mvdan in 54e81b3
- internal/core/convert: avoid an allocation for "small" big.Int values by @mvdan in 72c8aac
- internal/core/adt: also use strings.ToValidUTF8 over x/text/encoding/unicode by @mvdan in b78f800
- internal/core/convert: use strings.ToValidUTF8 over x/text/encoding/unicode by @mvdan in 29aca5f...
v0.15.4
Evaluator
Fix a panic which could occur when using the error built-in with cyclic references.
Fix a panic which could occur when loading @experiment(aliasv2) syntax with an invalid alias name.
cmd/cue
Relax the cue login --token validation to allow future Central Registry token types.
Encodings
Fix a bug in the TOML decoder where nested arrays were causing incorrect "duplicate key" errors.
Full list of changes since v0.15.3
- internal/cueversion: bump LanguageVersion for v0.15.4 by @mvdan in 50c137c
- internal/ci: bump Go and goreleaser for v0.15.4 by @mvdan in 8e3eaa9
- cmd/cue: relax login --token prefix validation by @rustyx in d0bd478
- cue/ast/astutil: fix nil pointer dereference in postfix alias error by @mvdan in c5df0af
- internal/core/debug: fix stack overflow in error formatting by @mvdan in bf7a40d
- encoding/toml: correctly check for duplicate keys with arrays by @mvdan in 4a5fd52
v0.15.3
Evaluator
Fix a panic which could occur when using Expr after LookupPath on a cue.Value.
cmd/cue
Fix a panic which could occur when using cue cmd tasks referencing definitions.
Fix a panic which could occur when cue get go encountered a Go enum type with zero named values.
Encodings
Fix a bug in the TOML decoder where nested arrays were not being correctly mapped to CUE values.
Full list of changes since v0.15.1
- internal/ci: bump Go and goreleaser versions by @mvdan in 8a91fed
- cmd/cue: avoid panic in
get gowhen an enum has zero named values by @mvdan in f544b9c - encoding/toml: forget nested arrays when starting a new array element by @mvdan in 641c64a
- tools/flow: support task results when defined via definitions by @mvdan in 6d86ce6
- cmd/cue: add test case for issue #2633 by @mvdan in 3544f15
- internal/core/adt: check opID before inheriting parent reqSets by @mvdan in 3cb0e2d
v0.15.1
Evaluator
Fix an evalv3 regression first introduced in v0.11.0 where the and built-in function started evaluating its arguments too eagerly, causing failures in cue def.
Fix an evalv3 regression where closedness info could be lost when using a comprehension.
Fix a bug where the evaluator would panic on alias cycles with dynamic fields rather than giving a good error.
LSP
Formatting standalone CUE files - either without a package name, or outside of a CUE module - now works correctly.
Fix a bug where trying to use "find references" on a CUE module with nested modules would cause a hang.
Fix a bug where resolving path roots did not work correctly in the presence of struct embeddings.
cmd/cue
Fix a regression in v0.15.0 where cue get go no longer skipped generating CUE files without any declarations.
Go API
Fix a bug in the subsume package where a struct with a pattern constraint did not subsume a closed struct with a matching field.
Rename the bootstrap build tag used in the internal/filetypes package to cuebootstrap to avoid conflicts with build tags in other Go modules.
Full list of changes since v0.15.0
- bump pinnedReleaseGo and LanguageVersion for v0.15.1 by @mvdan in 350755e
- lsp/fscache: improve removal of phantom package decls by @cuematthew in bcc9a45
- internal/lsp: format standalone files without phantom pkg names by @cuematthew in bf16055
- lsp/definitions: correct resolution of path roots by @cuematthew in e64569f
- lsp/definitions: add test to show faulty resolution by @cuematthew in f2076ae
- lsp/cache: stop nested modules from breaking find-references by @cuematthew in 6d75085
- internal/core/compile: don't panic on an alias cycle with a dynamic field by @mvdan in cf6c597
- internal/core/compile: revert
andto use Func instead of RawFunc by @mvdan in 37e8637 - cue/testdata: add test case for #3719 by @mvdan in de5328e
- internal/core/subsume: fix duplicate logic for pattern constraints by @mvdan in a229275
- internal/core/subsume: add test cases for pattern constraints by @mvdan in bca0a55
- internal/filetypes: use a less generic bootstrap build tag by @mvdan in 94f2f0e
- cmd/cue: do not emit empty CUE files in
get goagain by @mvdan in 819474c - cmd/cue: test that we don't emit empty CUE files without --outfile by @mvdan in e61516d
- internal/core/adt: check removed scope per conjunct by @mvdan in 2e8e111
- cue/testdata: add a test case for #4180 by @mvdan in f81118c
v0.15.0
Changes which may break some users are marked below with:
Note that this release no longer includes a checksums.txt asset; GitHub now provide digests natively.
LSP
This release includes the initial version of cue lsp - with support for "go to definition", "find references", rename, code completion, hover documentation, and code formatting.
See our Getting Started wiki page for instructions on how to set it up with your editor.
Please report any bugs or missing features you encounter via the Issue tracker or via the #lsp channels on Discord or Slack.
Language
explicitopen experiment for #A...
The explicitopen per-file experiment enables the posfix ... operator to explicitly open closed structs, allowing additional fields to be added. This change simplifies CUE's semantics, reduces user confusion, and enables clearer expression of type extensibility patterns.
You can try this experiment by following our how-to guide. For more information, see the proposal on GitHub and the spec change patch.
aliasv2 experiment
The aliasv2 per-file experiment implements the new "postfix aliases" syntax, and introduces a "self" predeclared identifier referring to the innermost surrounding struct or list.
You can try this experiment by following our how-to guide. For more information, see the proposal on GitHub and the spec change patch.
Other experiments
keepvalidators global experiment is now stable, meaning that CUE_EXPERIMENT=keepvalidators is always enabled.
With its proposal accepted, the structcmp per-file experiment is now stable with language.version at v0.15.0 or later, meaning that the @experiment(structcmp) attribute is unnecessary as it's always enabled.
Evaluator
⚠️ Removing evalv2
The old evalv2 evaluator, which previously could be re-enabled via CUE_EXPERIMENT=evalv3=0, is now deleted. The new evalv3 evaluator has been on by default since v0.13.0, and at this point our entire test suite including Unity is working.
Removing the old evaluator reduces significant load on development, as we were able to clear out 4000 lines of code, and simplify the internal types and code structure. This is a necessary step to unblock ongoing feature and performance work in the evaluator.
As a bonus, because the old and new evaluators shared many core evaluator types, removing the fields only used by the old evaluator yields modest memory usage improvements of around 4-6%.
Performance
Evaluating concrete CUE values no longer involves dependency analysis; this should result in modest speed improvements when marshaling to YAML, via either cue export -e expr -o yaml or yaml.Marshal.
Dependency analysis now avoids computing references more than once, which resolves an expontential performance issue for some configurations using chains of CUE references.
Add caching to a part of the typochecker algorithm; this has been measured to provide performance improvements of up to 30% on a few large projects.
cue/parser now reuses more memory, which results in parsing performance improvements of up to 30% and memory savings of up to 50%, especially when loading large CUE data files.
Other changes
File embedding via the @embed attribute has gained an allowEmptyGlob option, to allow glob patterns to match zero files without causing an error.
The evaluator now shows all user errors created with the error builtin when they can be related to a disjunction failure. Previously, the evaluator would try to only show user errors directly part of a disjunction error, but that caused too many omissions.
Some error positions which were lost in the transition from evalv2 to evalv3 have been reintroduced.
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 regression introduced in v0.12.0 where incomplete errors were not being handled consistently if they directly involved the top-level value.
A number of panics and error regressions in the evaluator which were reported since v0.14 have been fixed; thank you to all who reported these.
cmd/cue
A new cue help experiments command is introduced to document all available per-file and global experiments.
The cue fix --exp flag is introduced to rewrite files or packages to use new and experimental semantics with @experiment attributes.
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 mod resolve gains a --deps flag that lists all dependencies of the current module and which registries they resolve to.
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.
Fix a regression introduced in v0.9.0 where loading a qualified pattern like ./...:pkgname no longer filtered files based on the package name given.
cue get go now stops on any Go package loading error. Trying to continue in the presence of syntax or type-checking errors could lead to generating incorrect CUE.
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 currently very experimental, and many features are missing. For now, it can only generate a single version of JSON Schema, draft/2020-12.
The YAML library in the archived Go module gopkg.in/yaml.v3 has been replaced by go.yaml.in/yaml/v3, an active fork now maintained by the YAML organization.
cue exp gengotypes is improved to handle more edge cases with CUE package imports which could result in broken Go code.
The Protobuf decoder has been tweaked to not require files such as google/protobuf/timestamp.proto to exist on disk, given that they are mapped to CUE standard library APIs directly.
The Protobuf decoder has also been tweaked to support fully qualified references such as my.pkg.name.MessageName.
A bug is fixed in the TOML decoder where sub-table keys could incorrectly lead to duplicate key errors.
Standard library
The net package has gained new AddIP and AddIPCIDR functions to add numerical offsets to IP addresses or CIDR networks.
The Atoi, ParseInt, and ParseUint functions in the strconv package now work on integers with unlimited precision, like the rest of the CUE evaluator, rather than just a maximum of 64 bits.
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.
The new encoding/yaml.Decoder API allows decoding a stream of YAML documents, given that existing APIs did not support streams of multiple YAML documents.
encoding/json gains JSON Pointer APIs, which are already useful in packages like encoding/jsonschema.
cue/ast introduces PostfixExpr to support upcoming additions to the language syntax.
cue/ast introduces StringLabelNeedsQuoting to determine whether a string label needs to be quoted when used in CUE syntax.
cue/ast introduces NewStringLabel to create an ast.Label as either an unquoted identifier or a quoted string, depending on whether the string label needs quoting.
tools/fix has gained new APIs to fix configs to use an active experiment, as well as fixing configs to a newer language version.
cue introduces a Path.Append convenience method.
cue/build.Instance.Match is removed, given that it was never set to any value at any point since it was added.
cue/token is adjusted so that node positions within a file never result in an offset which is outside the bounds of the file. This could easily lead to subtle bugs or panics when using node position offsets.
v0.15.0-rc.1
Changes which may break some users are marked below with:
Note that this release no longer includes a checksums.txt asset; GitHub now provide digests natively.
cmd/cue
cue mod resolve gains a --deps flag that lists all dependencies of the current module and which registries they resolve to.
LSP
The LSP now supports finding references to a declared name, which can be thought of as the opposite of "go to definition". Using the same underlying mechanism, the LSP now also supports the "rename" operation.
A number of bugs have been fixed, such as package imports not working in standalone files when inside a valid CUE module.
Go API
The new encoding/yaml.Decoder API allows decoding a stream of YAML documents, given that existing APIs did not support streams of multiple YAML documents.
Full list of changes since v0.15.0-alpha.3
- cue/load: ensure that Config.ModuleRoot is clean, like Config.Dir by @mvdan in 14472be
- cue/load: correctly handle the filesystem root as Config.ModuleRoot by @mvdan in d7a839b
- encoding/jsonschema: avoid redundant patternProperties in Generate by @rogpeppe in a8385f8
- cmd/cue: update help text to reflect renamed experiment by @jpluscplusm in 7d0090a
- cmd/cue/cmd: add --deps flag to 'cue mod resolve' by @rogpeppe in 15afd50
- cue/load: add test case showing an error when Config.ModuleRoot=="/" by @mvdan in 44dba4e
- internal/ci/goreleaser: actually disable checksum generation by @mvdan in 93c434c
- all: remove two obsolete and commented-out APIs by @mvdan in 25322ae
- lsp/definitions: call pos.Offset() directly by @cuematthew in 64182de
- internal/lsp: support standalone files with imports in modules by @cuematthew in 7dcbdf6
- internal/lsp: add support for rename by @cuematthew in 24300be
- internal/lsp: support references with definitions by @cuematthew in 6feb520
- cmd/cue: adjust
cue get go --outfilelogic by @mvdan in 6491013 - cue/token: rewrite Pos.Before in terms of Pos.Compare by @mvdan in 6c2aa6a
- cue/token: don't unpack line info in Pos.Compare by @mvdan in 9623737
- cue/token: remove unnecessary Pos.file nil checks by @mvdan in 852de61
- cue/token: don't unpack line info in Pos.Offset by @mvdan in 8972e06
- cue/token: don't unpack line info in Pos.Filename by @mvdan in 6543708
- cue/token: reuse File.Offset in File.position by @mvdan in f4ba49b
- cue/ast/astutil: use
go fix -inlineon ImportPathName by @mvdan in 1850e9b - internal/core/layer: rudimentary implementation of layers by @mpvl in 654b5c0
- internal/core/adt: set t.id only once by @mpvl in aae1e07
- internal/lsp: wire UsagesForOffset into the LSP by @cuematthew in bdc3901
- lsp/definitions: implement UsagesForOffset by @cuematthew in 5303c60
- lsp/definitions: add ability to reset definitions analysis by @cuematthew in aba5ee2
- lsp/rangeset: add String methods by @cuematthew in bfe4aba
- encoding/yaml: add Decoder for streaming YAML documents by @mpvl in 738e6e4
- all: start leveraging
go fix -inlineby @mvdan in 70d6a9c - all: go fix -inline ./... by @mvdan in 279e355
v0.15.0-alpha.3
Changes which may break some users are marked below with:
Note that this release no longer includes a checksums.txt asset; GitHub now provide digests natively.
Evaluator
aliasv2 experiment
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
siblingsfunction 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...
v0.14.2
Evaluator
Fix an unintended evalv2 regression in v0.14.1; the change only intended to affect evalv3.
Fix a panic in the parser which could occur when @experiment() file attributes are invalid.
Fix an edge case where binary streams with ''' sequences would not roundtrip correctly.
Full list of changes since v0.14.1
- internal/cueversion: bump for v0.14.2 by @mvdan in d3fd2fb
- internal/ci: build releases with Go 1.24.8 by @mvdan in 9d0a821
- update golang.org/x/... dependencies where we can by @mvdan in 3700db6
- cue/literal: properly include hashes in escape sequences in bytes by @mvdan in e307749
- cue/literal: add test case for lossy bytes quoting by @mvdan in cfb31dc
- cue/parser: backport a fix to avoid panics on experiment errors by @mvdan in 15e00c7
- internal/core/adt: revert unintended behavior change in evalv2 by @mvdan in 3bacdcc
v0.15.0-alpha.2
Changes which may break some users are marked below with:
Evaluator
self experiment
The self experiment enables a new "self" predeclared identifier, which refers to the innermost surrounding struct or list, or the top level if none exist.
Once a module's language.version targets v0.15.0, this can be enabled via the file attribute @experiment(self). The introduction of a new predeclared identifier should be a fully backwards compatible change. The LSP also adds support for the self experiment.
For more information, see the proposal on GitHub and the spec change patch.
Other changes
keepvalidators experiment is now stable, meaning that CUE_EXPERIMENT=keepvalidators is always enabled.
With its proposal accepted, the structcmp experiment is now stable with language.version at v0.15.0 or later, meaning that the @experiment(structcmp) attribute is unnecessary as it's always enabled.
The evaluator now shows all user errors created with the error builtin when they can be related to a disjunction failure. Previously, the evaluator would try to only show user errors directly part of a disjunction error, but that caused too many omissions.
Fix a regression introduced in v0.12.0 where incomplete errors were not being handled consistently if they directly involved the top-level value.
cmd/cue
A new cue help experiments command is introduced to document all available per-file and global experiments.
Fix a regression introduced in v0.9.0 where loading a qualified pattern like ./...:pkgname no longer filtered files based on the package name given.
LSP
Support is added for standalone CUE files, meaning any CUE file which is not part of a package inside a module. For example, a CUE file without a package declaration, or a CUE file outside of any CUE module.
Encodings
The YAML library in the archived Go module gopkg.in/yaml.v3 has been replaced by go.yaml.in/yaml/v3, an active fork now maintained by the YAML organization.
cue exp gengotypes is improved to handle more edge cases with CUE package imports which could result in broken Go code.
Go API
cue/ast.StringLabelNeedsQuoting determines whether a string label needs to be quoted when used in CUE syntax.
cue/ast.NewStringLabel creates an ast.Label as either an unquoted identifier or a quoted string, depending on whether the string label needs quoting.
cue/build.Instance.Match is removed, given that it was never set to any value at any point since it was added.
Full list of changes since v0.15.0-alpha.1
- cmd/cue/cmd: alias
cue help experimentby @rogpeppe in 5432a20 - internal/encoding/gotypes: handle CUE import aliases and duplicates by @phoban01 in ba534b5
- all: run cuetxtar garbage collection by @rogpeppe in 3e1e769
- internal/cuetxtar: implement garbage collection by @rogpeppe in a3eb068
- cue/ast: rename NewLabel to NewStringLabel by @mvdan in 869b034
- cue/build: remove the Instance.Match field, which was never set by @mvdan in dc3731d
- cue/literal: use Form.tripleQuote when quoting a string by @mvdan in af175ed
- cue/ast: remove commented out bits of code by @mvdan in ed355b0
- internal/core/compile: properly quote labels in error message paths by @mvdan in 01181e9
- cue/testdata: add a test case for quoting paths in evaluator errors by @mvdan in 08d34f9
- cue/format: remove unnecessary IsDefOrHidden check by @mvdan in 0010744
- encoding: use ast.StringLabelNeedsQuoting by @mvdan in a73e4cd
- cue/ast: add StringLabelNeedsQuoting by @mvdan in 1f88e1a
- internal/cuetdtest: consider the first item in a Matrix to be default by @rogpeppe in 1bc296c
- cue/stats: use
ResolveDepin arithmetic by @rogpeppe in 37ebf7e - cue/testdata/basicrewrite: use consistent spelling for "diff/explanation" by @rogpeppe in 8332fd5
- internal/core/adt: "write" stats file even when it isn't changing by @rogpeppe in 1873f84
- lsp/cache: be robust for nil file content by @cuematthew in ec216cf
- cue/parser: use more robust logic for detecting the end of an interpolation by @rogpeppe in afdde34
- cue/parser: add test case for string interpolation edge case by @rogpeppe in 276bcce
- cue/scanner: document how interpolations work by @rogpeppe in 7e9543b
- update all dependencies by @mvdan in 5944fee
- lsp/definitions: add support for the self experiment by @cuematthew in d4f9bfb
- lsp/definitions: completions from dot should be zero width by @cuematthew in 5c15642
- lsp/cache: prevent files from being both standalone and module/package by @cuematthew in 9357acf
- cue/ast: tweak ParseImportPath to treat
:pkgnameas.:pkgnameby @mvdan in 0a41be8 - cmd/cue: add a test case for the recent
:pkgnameCLI argument regression by @mvdan in a880c06 - lsp/cache: add support for standalone files by @cuematthew in 632f9b7
- internal/lsp: refactoring by @cuematthew in ab67c05
- cue/load: respect package qualifiers when matching wildcard packages by @rogpeppe in a862f84
- cue/loader: add test for issue 4110 by @rogpeppe in 36bcb3e
- internal/core/adt: add Kind.AllKinds and Kind.Count methods by @rogpeppe in 313e0c1
- internal/export: cater for NodeLink by @rogpeppe in b2a7b29
- cue: add test for issue 4093 by @rogpeppe in 47dab36
- cmd/cue: simplify when printing imported CUE schemas by @mvdan in 16118b3
- encoding/xml/koala: use ast.NewLabel by @mvdan in 880df5b
- internal/encoding/yaml: use cue/ast.NewLabel by @mvdan in 43c8a39
- cue/ast: introduce NewLabel helper for regular fields by @mvdan in 8561bce
- cmd/cue: remove debug print in
get goby @mvdan in 91d2572 - internal/core/convert: use reflect.Value iterator methods by @mvdan in be9298b
- internal/core/adt: improve structure sharing for _ by @mpvl in 458b038
- internal/ci: update various action dependencies by @mvdan in 79e9f72
- swap gopkg.in/yaml.v3 for go.yaml.in/yaml/v3 by @mvdan in 2502321
- cue/load: add test case for the fixed issue 741 by @mvdan in b74aa03
- all: consistently split test table structs by @mvdan in 43fd8bc
- internal/core/adt: make Vertex.Elems return an iterator by @mvdan in e95b0f9
- cue: deduplicate work from adt.Vertex.Elems by @mvdan in 258881a
- all: swap len([]rune(s)) for utf8.RuneCountInString(s) by @mvdan in 2de87fb
- cmd/cue: remove the last use of
shin testscripts by @mvdan in 25d062b - doc/ref/spec.md: some formatting and typo fixes by @mpvl in 139b17a
- doc/ref/spec.md: support unary == bound by @mpvl in 3500cef
- doc/ref/spec.md: support comparing values of different types by @mpvl in c356290
- internal/cueexperiment: make keepvalidators stable by @mpvl in c9da2b2
- cmd/cue: include global experiments in experiment help by @mpvl in 062fc5b
- internal/cueexperiment: standardize experiment lifecycle system by @mpvl in 9867177
- cmd/cue: added cue help experiments command by @mpvl in f1feade
- internal/core/adt: accept structcmp experiment by @mpvl in 8572198
- cue: implement "self" by @mpvl in 28641c0
- cmd/cue: test the handling of interrupt signals by @mvdan in 8e34149
- cmd/cue: treat top-level incomplete errors consistently by @mpvl in 26efa72
- cmd/cue: add test for issue 4079 and 4029 by @mpvl in 07635e5
- cue/testdata: add fixed test case for issue 3743 by @mvdan in bae3189
- cmd/cue: add test for issue 4005 by @mpvl in 1fc8f9d
- internal/core/adt: show all user errors by @mpvl in 519b41f...
v0.15.0-alpha.1
This release removes the old evalv2 evaluator, adds the explicitopen language experiment, and introduces an initial version of cue lsp.
Changes which may break some users are marked below with:
Evaluator
⚠️ Removing evalv2
The old evalv2 evaluator, which previously could be re-enabled via CUE_EXPERIMENT=evalv3=0, is now deleted. The new evalv3 evaluator has been on by default since v0.13.0, and at this point our entire test suite including Unity is working.
Removing the old evaluator reduces significant load on development, as we were able to clear out four thousand lines of code and simplify the internal types and code structure. This is a necessary step to unblock upcoming feature work in the evaluator.
As a bonus, because the old and new evaluators shared many core evaluator types, removing the fields only used by the old evaluator yields modest memory usage improvements around 4-6%.
explicitopen experiment for #A...
The explicitopen experiment enables the posfix ... operator to explicitly open closed structs, allowing additional fields to be added. This is a breaking change to the language which we are starting to transition towards; many users found the existing embed semantics to be confusing.
Furthermore, the existing semantics greatly complicated the evaluator and prevented significant performance optimizations. The new semantics also resolve a number of limitations, such as not being able to enforce a schema at the package level without opening up the schema due to the necessary embedding.
Once a module's language.version targets v0.15.0, this can be enabled via the file attribute @experiment(explicitopen). To automatically convert files or packages to the new semantics, use cue fix --exp=explicitopen. Once the proposal is accepted, we intend to provide a command to safely upgrade a module to use the new semantics, without affecting its dependencies nor dependents.
For more information, see the proposal on GitHub and the spec change patch.
Other changes
A number of panics and error regressions in the evaluator which were reported in the last month have been fixed; thank you to all who reported these.
Dependency analysis now avoids computing references more than once, which resolves an expontential performance issue for some configurations using chains of CUE references.
Evaluating concrete CUE values no longer involves dependency analysis; this should result in modest speed improvements for users of standard library APIs such as yaml.Marshal.
Some error positions which were lost in the transition from evalv2 to evalv3 have been reintroduced by a few fixes.
File embedding via the @embed attribute has gained an allowEmptyGlob option, to allow glob patterns to match zero files without causing an error.
cmd/cue
The cue fix --exp flag is introduced to rewrite files or packages to use new and experimental semantics with @experiment attributes.
cue get go now stops if loading the given Go packages resulted in any errors. We would previously try to continue in the presence of some syntax or type-checking errors, but this could easily lead to subtle bugs such as panics or generated CUE which was incomplete or incorrect.
LSP
This alpha release includes the initial version of cue lsp - with support for "go to definition", code completion, hover documentation, and code formatting.
See our Getting Started wiki page for instructions on how to set it up with your editor.
Please report any bugs or missing features you encounter via the Issue tracker or via the #lsp channels on either Discord or Slack.
Encodings
The Protobuf decoder has been tweaked to not require files such as google/protobuf/timestamp.proto to exist on disk, given that they are mapped to CUE standard library APIs directly.
The Protobuf decoder has also been tweaked to support fully qualified references such as my.pkg.name.MessageName.
A bug is fixed in the TOML decoder where subtable keys could incorrectly lead to duplicate key errors.
Standard library
The net package has gained new AddIP and AddIPCIDR functions to add numerical offsets to IP addresses or CIDR networks.
The Atoi, ParseInt, and ParseUint functions in the strconv package now work on integers with unlimited precision, like the rest of the CUE evaluator, rather than just a maximum of 64 bits.
Go API
encoding/json gains JSON Pointer APIs, which are already useful in packages like encoding/jsonschema.
cue/ast introduces PostfixExpr to support upcoming additions to the language syntax.
tools/fix has gained new APIs to fix configs to use an active experiment, as well as fixing configs to a newer language version.
cue introduces a Path.Append convenience method.
cue/token is adjusted so that node positions within a file never result in an offset which is outside the bounds of the file. This could easily lead to subtle bugs or panics when using node position offsets.
cue/errors is adjusted so that Positions only collects printable positions, to prevent printing empty positions in the CLI.
cue/ast deprecates the File.Imports field in favor of the File.ImportSpecs iterator method. The iterator method File.ImportDecls is also introduced for completeness.
cue.ResolveReferences option API is now removed.
cue/parser.DeprecationError.Version is deprecated, as tracking CUE language versions via integers has not been used since v0.4.3, and the mechanism was never properly documented.
Full list of changes since v0.14.0
- lsp/definitions: Add support for explicit-open by @cuematthew in cbb9e94
- .claude: wildcards are only supported at the end of a command by @mvdan in 64f9a26
- cmd/cue: stop using an internal test package by @mvdan in 1c4b8f6
- Revert "cmd/cue: use os/signal.NotifyContext for the root command context" by @mvdan in 1061fcd
- cue: add Path.Append method by @mpvl in 9ddc9b8
- internal/task: factor out task function creation by @mpvl in 4336f31
- tools/flow: make running variable more robust by @mpvl in c87a88b
- tools/fix: implement __closeAll wrapper insertion by @mpvl in c5f9ed8
- internal/core/export: disable pivotter for data output by @mpvl in a964aef
- internal/core/adt: avoid computing duplicate dependencies by @mpvl in f545420
- internal/core/dep: add test for Issue #4064 by @mpvl in c5f1aa9
- internal/core/dep: keep track of number of dependencies computed by @mpvl in 7ebdd14
- internal/core/adt: reuse allocations of source-less booleans by @mvdan in 2135d16
- internal/core/adt: re-enable TestScheduler by @mvdan in fbc7d36
- lsp/server: make formatter be a noop if result is unparsable by @cuematthew in 1b05645
- lsp/server: add test to show bad formatting by @cuematthew in 3e45a4d
- update cobra and pflag dependencies by @mvdan in 0667e66
- update golang.org/x/... dependencies by @mvdan in fff2509
- internal/ci: upgrade to actions/setup-go@v6 by @mvdan in 467726a
- internal/ci: update versions of Go and goreleaser for alpha.1 by @mvdan in a486317
- cue/token: clarify docs on printable positions by @mvdan in 8799675
- internal/lsp: implement hover by @cuematthew in 723e0de
- lsp/cache: refactor and reduce duplication by @cuematthew in cd1a950
- lsp/cache: prevent infinitely loading the same package by @cuematthew in 20531e1
- internal/core:adt: don't report errors beyond disjunction boundary by @mpvl in e999d98
- internal/core/adt: revert "report comprehension error at task level" by @mpvl in 58e6f08
- internal/core/adt: report comprehension error at task level by @mpvl in d77101d
- internal/core/adt: add tests for Issue 4055 and 4056 by @mpvl in 9ce1ae1
- internal/core/adt: disable part of memory reclamation for disjunctions by @mpvl in a6fa43f
- internal/core/adt: start clean up of IsClosedStruct by @mpvl in 7ceab16...