Releases: cue-lang/cue
v0.16.0-rc.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!
β οΈ else is now part of the try experiment
v0.16.0-alpha.2 introduced the else comprehension clause, available to any module targetting language version v0.16.0 or later without needing to use an experiment.
Thanks to user feedback and design discussions, we have come to realize that the existing design needed tweaking. for comprehensions now use a fallback token rather than else in order to clarify intent, and we have also restricted the use of else in chains of comprehension clauses, which could easily cause confusion.
Given how late in the release cycle we already are, and understanding that we probably will want to make further tweaks to this feature before it's stable, we have decided to put this language feature behind a file experiment after all.
Rather than adding @experiment(else), we have chosen to bundle this with @experiment(try), given that try without else does not make much sense.
For more information on the up-to-date else and fallback clauses, follow our how-to guide, or read the updated spec change patch.
Evaluator
Fix a regression introduced by v0.16.0-alpha.2 where cue cmd could suddenly report undefined or missing fields from data in non-tool CUE files.
cmd/cue
cue exp writefs gains an encoding optional field for regular files, to specify an encoding rather than infer it from the filename extension.
Full list of changes since v0.16.0-alpha.2
- lsp/eval: add support for comprehension else/fallback by @cuematthew in e2d8f7b
- cmd/cue: support explicit encodings in
exp writefsby @mvdan in d0eca3f - cmd/cue: rewrite
exp writefswith internal/filetypes and internal/encoding by @mvdan in 766668d - cmd/cue: add first
exp writefstestscript by @mvdan in 00eddbf - internal/core/adt: missed missing missing by @mpvl in 8732213
- cue/parser: simplify else/fallback clause rules by @mpvl in 0cbc9a1
- cue/parser: restrict else to single clause only by @mpvl in 28f0246
- cue: add fallback keyword for for comprehensions by @mpvl in fe9f503
- cue/testdata: rename out/eval to out/evalalpha when appropriate by @rogpeppe in c76dc5a
- cue/build: fix stale identifier resolution across instances by @mvdan in dd7361a
- cmd/cue: add regression test for issue 4275 by @mvdan in 791e697
- encoding/yaml: improve ast.StructLit and ListLit positions by @cuematthew in cde471e
- cmd/cue: be more helpful when publishing a module without source by @mvdan in 3dfa50a
- encoding/jsonschema: remove net/url.Parse workaround for Go 1.26 by @mvdan in 6cce9bc
v0.16.0-alpha.2
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!
The new try experiment
This experiment adds a try clause in comprehensions as well as the use of ? in field selectors. This addition to the language intends to provide a more concise syntax for handling optional fields without the risk of unintentionally swallowing errors.
You can try this experiment by following our how-to guide. For more information, see the proposal on GitHub and the spec change patch.
The new else comprehension clause
This change adds an optional else clause for CUE modules targetting the language version v0.16.0 or later. With this addition to the language, an if or for comprehension may be followed by an else clause which triggers when the comprehension produces zero values.
Note that this feature is not an experiment; it is available to any CUE module targetting the language version v0.16.0 or later.
You can try this feature by following our how-to guide. For more information, see the full patch which includes the changes to the spec, or read the pre-release version of the language spec.
Evaluator
A number of changes were made to improve support for using cue.Values concurrently; see Issue #2733 for more details and ongoing progress.
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
The global --verbose and --trace flags have been moved to the cue get go and cue trim commands respectively, as they were the only ones actually using those flags, and this could be confusing to users.
Fix a bug where loading ./...:pkgname could lead to loading directories with zero CUE files as instances, which could cause poor performance for CUE packages with multiple parent directories.
LSP server
Code Actions: two code actions are now provided, Add surrounding struct braces and Remove surrounding struct braces, which convert between
a: b: c
and
a: {
b: c
}
with the cursor on b.
Initial LSP support for editing embedded JSON files. This feature provides completions and hover-docs when editing JSON files which are embedded into CUE via the @embed attribute. A teaser video is available on YouTube. Support for embedded YAML files will appear soon.
Several bug fixes, including better behaviour for files and directories with spaces; improvements for value aliases (foo: L=x); LSP rename now provides placeholder text.
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
Add support for encoding YAML tags like key: !Custom value by using CUE attributes like key: "value" @yaml(,tag="!Custom").
Standard library
The net package adds CompareIP to compare two IP addresses, which can be useful for computing with IP ranges.
The net/http package adds Serve as an experimental API to listen on a port and serve HTTP requests.
The tool/file package adds Symlink to create symbolic links.
Go API
cue/ast gains the NewPredeclared and Ident.IsPredeclared to mark and detect identifiers referencing predeclared names like error or int rather than fields which may shadow those names in the current scope.
cue/token.Compare now sorts absolute paths before relative ones, to ensure consistent behavior between Unix-like systems and Windows.
cue.Instance.Eval method is now removed.
Full list of changes since v0.16.0-alpha.1
- internal/core/export: fix self-referential lets for recursive definitions by @mvdan in c257634
- internal/core/compile: avoid double error for invalid optional references by @mpvl in c1be2bb
- update all dependencies by @mvdan in 9fb0173
- internal/core/adt: add regression test for error() in pattern constraint keys by @mvdan in 50a0a5e
- internal/core/adt: fix structural cycle hang with braced selectors by @mvdan in 36702fd
- cmd/cue: add and unskip tests for invalid task type errors by @mvdan in db4afc1
- internal/core/dep: fix stack overflow on recursive definitions in dep analysis by @mvdan in 0b49a54
- internal/core/dep,internal/core/export: fix stack overflow on recursive definitions by @mvdan in d0e2ab6
- tools/flow: skip phantom tasks from eliminated conditional branches by @mvdan in 7fb912e
- encoding/gocode: fix test by @rogpeppe in 98ca6e3
- internal/core: remove import path to instance mapping by @rogpeppe in b3d9ffc
- doc/spec: use "custom errors" instead of "user errors" by @myitcv in baf8302
- internal/ci: explicitly set contents permission by @myitcv in 7cde504
- lsp/eval: Add support for try-clauses and optional path components by @cuematthew in 62de631
- cue/testdata: update stats for comprehensions/try.txtar by @mvdan in 20c1149
- internal/core/adt: implement try expressions by @mpvl in f2e8299
- cue/build: integrate identifier resolution into Complete by @mpvl in 1aeb33e
- lsp/fscache: ignore ASTs which have no absolute positions by @cuematthew in 2585b3b
- cue/ast,cue/ast/astutil: add NewPredeclared and IsPredeclared for builtin references by @mpvl in 8405422
- internal/core/adt: fix else clause duplication in comprehension field splitting by @mvdan in 40356ab
- cue/load: improve error for major-only version packages outside a module by @mvdan in 7675369
- cmd/cue/cmd: add test coverage for absolute packages with cue cmd by @mvdan in f5e266a
- encoding/yaml: add support for YAML tags via
@yaml(,tag)attribute by @jonas-meyer in b1a58bd - internal/astinternal: omit ILLEGAL tokens in debug print by @mpvl in 23736eb
- cue: clarify that Schema is only useful for Value.Subsume by @mvdan in bb18d7b
- lsp/cache: expand completion range of fields in json for double-quotes by @cuematthew in b1c63da
- all: start using "else" in comprehensions by @mvdan in 3f2f654
- tweak Claude's allow and deny settings further by @mvdan in ef6bb80
- internal/ci: disable checkout persist-credentials by default by @myitcv in 069eac9
- cue/load: do not load non-CUE directories as instances by @rogpeppe in a4d2a6f
- cue/load: add test case for non-package directories by @rogpeppe in 028411e
- cmd/cue: deflake cue_after test by @rogpeppe in 4504db0
- all: use reflect.TypeAssert in three more places by @mvdan in 58cbd0c
- cue/internal: Make ToFile optionally preserve StructLits by @cuematthew in ec3e289
- all: re-apply
go fix -any=false ./...after Go version bump by @mvdan in 8579c46 - lsp/cache: completions must not return null items list by @cuematthew in 75ee97a
- internal/core/export: fix panic in relPathLength for BinaryExpr by @mvdan in 788eeed
- tools/fix: use ast.Predeclared to avoid shadowing in value alias conversion by @mvdan in 08a7ec3
- cue/ast,cue/ast/astutil: add Predeclared sentinel for builtin references by @mvdan in 42cc85f
- tools/fix: add tests for value alias conversion when "self" is in scope by @mvdan in 3dacb0c
- cue/ast/astutil: fix false positive in label expression check for let clauses by @mvdan in a93bcc1
- cmd/cue/cmd: add failing test for i...
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