Changes which may break some users are marked below with: ⚠️
Evaluator
Several long-standing cycle-detection bugs have been fixed, such as self-referential uses of matchN and matchIf, self-feeding disjunctions, and comprehensions that read a let binding which refers back to the comprehension's own fields.
Fixed a bug where the same package imported via different qualified import paths (e.g. foo.com/bar@v0 or foo.com/bar:baz) did not share the same hidden field namespace.
Fix a data race which could occur when concurrently loading the same imported packages.
cmd/cue
Module replace directives
cue now supports replace directives, letting you substitute a module dependency with a local directory or a different remote module during development - for example while testing a fix to a dependency before it is published, or to replace a dependency with a fork including improvements.
This configuration lives in cue.mod/local-module.cue, which is excluded when publishing to registries. cue mod edit and cue mod tidy gain support for maintaining this file.
We have also published a how-to guide on replacing a dependency with a local module.
Read the full design and provide feedback in the proposal, or read the cue.mod/local-module.cue reference docs.
Other changes
Resolving an unversioned import from a dependency module now respects that module's own default major version, instead of always using the main module's default.
Fix a bug where the flag cue export --path was ignored when the inputs were pure CUE.
cue import --with-context now ensures that data represents the original raw input data, and not its interpretation like JSON Schema.
Command input parsing is improved so that CUE packages can come after data files, such as cue vet -c data.yaml ./schema.
A $CUE_CACHE_DIR directory is no longer required when loading CUE without external dependencies.
Standard library
Add time.ToUnix and time.ToUnixNano, which convert an RFC3339Nano time value into seconds or nanoseconds since the Unix epoch, complementing the existing Unix builtin.
Go API
⚠️ The modconfig.Registry interface is changed to report default major versions, which is required for resolving unversioned imports against each dependency module's own defaults. Clients that implement or wrap the interface will need to update. The new interface is future-proofed for upcoming modules changes.
Full list of changes since v0.17.0-alpha.2
- cmd/cue: reject non-string label values for --path by @mvdan in 5a0f4f7
- cmd/cue: add test for --path with a non-string label value by @mvdan in 772d1d3
- update dependencies ahead of v0.17.0-alpha.3 by @mvdan in b7d1625
- cmd/cue: drop github.com/google/shlex test dependency by @mvdan in 69bf7d7
- cue/load: accept package arguments after file arguments by @mvdan in dd80111
- cmd/cue: add test for package arguments listed after files by @mvdan in ed3622b
- internal/cuetxtar: port old stats framework by @mpvl in 489b249
- encoding/ini: pass token.Pos through the decoder directly by @mvdan in 91a3f18
- encoding/ini: minor decoder cleanups by @mvdan in 5b8ba6e
- encoding/ini: reject section and property name collisions by @mvdan in eb8ac73
- cue/testdata: add missing error output for issue2627 by @mpvl in 092c281
- Revert "cue/errors: augment paths of wrapped errors" by @mvdan in a361a5b
- cmd/cue: add replace directive support to mod edit by @rogpeppe in 9984dae
- internal/mod/modload,mod/modzip,cmd/cue: tidy and publish two-file modules by @rogpeppe in 5adf7f5
- mod/modfile,cue/load: read replace directives from local-module.cue by @rogpeppe in 12ecd27
- all: add core plumbing for module replace directives by @rogpeppe in 74d78c1
- cue/build,cue/load: fix hidden-field namespace for versioned imports by @rogpeppe in b159ed1
- cue/testdata: add regression test for issue #2937 by @mvdan in 39d5c4e
- cue/errors: augment paths of wrapped errors by @mvdan in 71c13d2
- pkg/encoding/json: add test for Validate hiding the failing field by @mvdan in 8507be6
- pkg/time: add ToUnix and ToUnixNano builtins by @mvdan in d5a3fb7
- cmd/cue: honor -l/--path when exporting CUE values by @mvdan in 0abb86e
- cmd/cue: add test for export -l with CUE output by @mvdan in 14d7d4d
- all: make more use of string cut/trim/contains APIs by @mvdan in 40ad26f
- internal/mod/modpkgload,cue/load: resolve major version defaults per module by @rogpeppe in b24b39c
- cue: format builtin call's function operand as a bare reference by @mvdan in 7392c8e
- cue: add test for builtin call function operand formatting by @mvdan in 72ff12b
- cue/parser: support try clauses in list literals by @mvdan in b0a4125
- cmd/cue: point to 'cue help flags' from the --with-context flag by @mvdan in 8b9f8be
- cmd/cue: evaluate --with-context labels against the source data by @mvdan in 9bb021f
- mod/modconfig: lazily initialize registry clients by @mvdan in 44f24f1
- cmd/cue: test various command scenarios without cache/config dirs by @mvdan in 445c76d
- cmd/cue: add test for label references with jsonschema import by @mvdan in f33b9de
- internal: only wrap over-long generated comment lines by @mvdan in b682521
- encoding/jsonschema: add test for doc comment reflow by @mvdan in fa683ed
- internal/core/adt: handle cycle placeholder for composite builtins by @mpvl in 32244d1
- internal/core/adt: guard nodeContext free on refCount by @mpvl in 03748aa
- internal/cuetxtar: fix inline runner writeStruct cycle and BasicType embed by @mpvl in afa5272
- cue/testdata: add test case demonstrating #2627 reopen by @mpvl in 684e354
- internal/core/adt: resolve imports to a per-evaluation instance by @mvdan in 86eb4f1
- cmd/cue: add test cases for issues 4370 and 4371 by @rogpeppe in 230bbbb
- internal/mod: minor module-related code improvements by @rogpeppe in 964c012
- internal/core/adt: test optional field referencing pushed-down comprehension by @mvdan in 32e6da5
- encoding/jsonschema: compile CRD schema only once by @mvdan in 139794b
- internal/core/adt: attribute failed try references to the owning body by @mvdan in 8c8c47c
- cue/testdata: add regression tests for nested try clauses by @mvdan in f7a59da
- internal/core/adt: fire comprehensions on let-bound self references by @mvdan in f6d7894
- internal/core/adt: add test for comprehensions on let-bound self references by @mvdan in c60ba81
- internal/core/adt: bound self-feeding disjunction recursion in cycle detection by @mvdan in 43d216f
- cue/testdata: add a test for the cycle-detection blowup of issue #4377 by @mvdan in e7d5121
- cue: add regression test for FillPath exporting fields as optional by @mvdan in 00df6eb
- internal/core/compile: detect structural cycles in self-referential matchIf by @mvdan in ec1313c
- internal/core/compile: detect structural cycles in self-referential matchN by @mvdan in d1a6540
- cue: accept a leading index in ParsePath by @mvdan in 0b61fdf
- cue: add TestPaths cases for a leading index in a path by @mvdan in a035333
- cue: give each TestPaths case its own CUE input by @mvdan in 5cf0e58
- pkg/list: add regression test for list.Contains with defaults by @mvdan in 7c6d8ae