v0.6.0
The main focus of this release is the introduction of required fields, as well as fixing a number of issues and regressions introduced in the v0.5.0 release.
As a reminder: users can register their projects with unity, our regression and performance testing setup. unity is used to ensure that a project’s CUE evaluations do not unexpectedly stop working, or regress in terms of performance. unity continues to catch multiple issues with each release. Adding your project to unity not only guarantees that we will not break your tests (if we do, we will work with you to fix your CUE code), but it also helps to improve the quality of each CUE release. Follow this link to learn more about Unity, install it, or get in touch with any questions.
Thank you to @4ad, @Abirdcfly, @alexandear, @chee-zaram, @eraserhd, @ghostwheel42, @joanlopez, @jpluscplusm, @kcburge, @mpvl, @mvdan, @myitcv, @rogpeppe, @toshi0607, and @zeithaste for contributing to this release!
API
CL 543335 adds arch to set of injectable system variables understood by cue/load. The text at cue help injection explains how this in more detail.
CL 552142 adds support for zero values in cue.Value.Float64, which has the effect of fixing the error when attempting to use strconv.FormatFloat with a zero value.
CL 548783 fixes a long-standing bug to make HTML escaping in JSON an opt-in. This means that cue export now respects the --escape flag when set, and encoding/json only escapes HTML when HTMLEscape is used.
Language
Required fields
The main focus of the v0.6.0 release is the introduction of required fields.
CUE already supports the “optional field constraint”, denoted foo?: value.
Required fields add a “required field constraint”, denoted foo!: value, which is like foo?: value, but requires a regular field be provided for foo (a field foo: without !: or ?:).
We refer to optional field constraints and required field constraints collectively as “field constraints”.
As a general rule, all data and data templating should be defined with regular fields, whereas schemas would be defined in terms of field constraints. Of course, CUE being CUE, mixing these two fields is allowed: this rule is not a restriction but suggested as a matter of style and proper usage.
Here are some examples of how exclamation marks can be used to express things that were previously not possible.
#Def: {
kind!: "def"
intList!: [...int]
}Using required fields can also result in better error messages. Consider this schema:
#Person: {
name: string
age?: int
}Note that this is non-idiomatic, because our new guidelines suggest schemas should only be defined in terms of field constraints, but we will use this for illustration purposes.
Now consider this usage of #Person:
jack: #Person & {age: 3}In data mode, the error message here is currently jack.name: incomplete value string, which does not provide much actionable information to the user to help them fix the problem.
Now consider how #Person looks with required fields, idiomatically only using field constraints:
#Person: {
name!: string
age?: int
}
jack: #Person & {age: 3}Now the error message reads:
jack.name: field is required but not presentwhich more closely reflects the underlying problem..
This error could be resolved by adding jack: name: "Jack".
For more details and background on the change, please see the original required fields proposal.
Other changes
Whilst it should not be a breaking change from a CUE perspective, we have upgraded to use github.com/cockroachdb/apd/v3. We have also increased apd.Context precision from 24 to 34.
CL 551207 adds support for making dynamic fields optional or required. For example, the following is now possible:
x: "y"
(x): "foo"
(x)?: "foo"
(x)!: "foo"and yields:
x: "y"
y: "foo"CL 546886 removes support for old-style :: definitions. This also includes deprecation support. In a similar vein, CL 547011 removes the last vestiges of <foo>: T. This was once the notation for pattern constraints.
Spec
Various bug fixes, with special thanks to @nicuveo for raising many of these.
Builtins
The following four functions have been added to the net package:
PathEscapePathUnescapeQueryEscapeQueryUnescape
Thanks to @eraserhd for this change.
CL 549087 reimplements pkg/list.Sort. The resulting reduction in the number of allocations and other work gives rise to a ~80% reduction in running time against CUE benchmarks.
cmd/cue
CL 547212 improves the documentation for the -l flag passed to cue import. This addresses a frequent point of confusion in questions to GitHub Discussions and on Slack.
CL 550616 fixes cue get go to respect the --exclude flag for constants. This makes it possible to (for example) exclude all unexported identifiers from a cue get go run.
CL 555576 fixed an important bug where cmd/cue vet was not properly consuming all input data.
CL 556526 fixed a bug where CUE files beginning with an underscore were not being loaded when explicitly given as filename arguments.
WebAssembly (Wasm)
We have added preliminary support for Wasm. Users can compile code from any language and toolchain that supports Wasm into plugins that are dynamically loaded by CUE. Users can then call and use functions from these Wasm modules, just like they can use standard library functions.
See the documentation at cuelang.org/go/cue/interpreter/wasm to learn more about Wasm and its current limitations.
Changelog
All changes
283 changesby area
all11
allremove a few more unused bits of codeallreplace godebug/diff with go-cmp/cmpallsed-replace all trivial uses of ioutilalluse strings.Builder in a few more placesallgo fix to remove old build tagsallmove pkg/gen and internal/cmd/qgo to build-ignored filesallmake HTML escaping in JSON an opt-inalladd tests to cover HTML escaping via encoding/jsonallremove duplicate words in commentsallcorrect typos and duplicate words in commentsallremove support for ::
cmd20
cmd/cuefix regression when injecting vars with cue cmdcmd/cueprint returned errorcmd/cue/cmdadd test for issue 2251cmd/cueproperly consume all data input in vetcmd/cueadd AllocBytes and AllocObjects to statscmd/cuerefactor our use of cobracmd/cuedo not defer closing files in fmt's loopcmd/cuecheck all file I/O errors in fmtcmd/cueremove skipped test scripts for fixing old definitionscmd/cue/cmdremove unused codecmd/cueavoid loading the current package incue helpcmd/cueremove fallback version code for Go 1.17cmd/cueremovego installlong testscmd/cueadd CUE_DEBUG_PARSER_TRACE environment variablecmd/cuerespect --exclude for constantscmd/cueadd test case for --excludecmd/cueremove use of stderr directivecmd/cueinclude Go in the version commandcmd/cuemention doc location for -l flagcmd/cueadd tests for issue 1926
cue42
cue/astclarify what is a valid identifiercue/loadfix Instances racecue/loadallow _*.cue files when explicitly listedcuefix some low hanging fruit from staticcheckcuereport useful error for uninitalized Contextcueadd extra TestAttributeString testcue/scanneradd Offset method and export DontInsertCommascueadd more attribute testscuedocument UnifyAcceptcue/astfix staticcheck warningscueallow iterating hidden fields and definitions of embedded scalarscue/astsupport specifying required fields in NewStructcueadd a "decimal" benchmarkcue/testdataadd regression test for #2244cue/interpreter/wasmadd user-level docscue/interpreter/wasmadd Wasm support for abi=ccue/loadreplace go-internal/semver with x/modcue/buildremove context.Context fieldcue/astfix IsValidIdent for _0cuemore support for required fields for selectorscuefail on required field in various casescueremove field typecueadd support for zero values in Value.Float64cue/load/tagsaddarchto set of injectable system variablescue/errorsremove redundant Sort call in list.sanitizecue/errorsbetter vetting of error formatscue/loadminimal module fetching implementationcue/loadavoid using ioutil.ReadDir to list directoriescue/astprepare for required fieldscue/loaddon't read parent directories in testscue/ast, cue/parserparse function typescue/contextsupport internal interpreterscue/load/internal/...copy pkgs from Go sourcecue/loadrefactor loadercue/loadmove code before refactoringcue/statsuse int64 for stats counterscue/testdata/benchmarksadd benchmark for sortcue/loadadd initial module.cue schemacue/loaduse cue package to interpret module.cue filecue/loadminor tweakscue/scannerremove block comment scanningcue/parserremove last vestiges of <foo>: T
doc4
doc/tutorialfix typodoc/ref/spec.mdfix uint16 and uint32 values rangedoc/tutorial/kubernetesfix build breakagedoc/ref/spec.mdadd required fields
encoding6
encoding/gocode/gocodecuse different generic type signatureencoding/gocode/gocodecallow cue.Contextencoding/jsoncheck that required fields are presentencoding/protobuf/jsonpbremove unused codeencoding/protobufremove unused codeencoding/openapiremove unused code
internal166
internal/core/depalways introduce Environment for Comprehension Value to fix panicinternal/core/depadapt Recurse to mimic dep.Visitinternal/ciuse cue-lang/cuelang.org workflow_dispatch for tipinternal/core/adtlets of comprehensions are multi letsinternal/core/adtalways mark let in comprehension as "complete"internal/core/adtfind late-stage conflict errorsinternal/core/adtadd tests to fix 2481internal/core/adtfix stack overflow with comprehensionsinternal/core/compilereject "_" as an alias nameinternal/core/depprevent passing "empty" vertices to tools/flowinternal/core/adtdo not delay processing of fieldsinternal/core/adtadd tests for upcoming issuesinternal/core/adtpass state to addListinternal/core/adtset scalar more proactivelyinternal/core/adtbetter error message for cyclesinternal/cicount number of Signed-off-by linesinternalremove a few unused APIsinternal/core/depfix recursive let processinginternal/core/depadd Dependency.Recurseinternal/core/depprepare for public APiinternal/core/adtmark comprehension key as dynamicinternal/core/depfurther improve dependency analysisinternal/core/depadd more tests ahead of changesinternal/core/depadd references and line in test outputinternaluse Scanner API to parse attributesinternal/core/deprequire importPath argumentinternal/core/dephandle inline composite literalsinternal/core/exportavoid _#def if unnecessaryinternalchange attribute tests to be less implementation-specificinternal/core/depadd and modify some tests for issue 2247internal/core/exportfix panic converting int label to identifierinternal/core/exportpreserve original field aliasesinternal/core/compilefix offset error in pattern aliasinternal/ciconsistently trigger Unity as porcuepineinternal/cibump Go and GoReleaser prior to alpha.2internal/core/exportavoid panics on computed comprehensionsinternal/core/adtreturn from Accept earlier for hidden fieldsinternal/core/adtadd missed errorinternal/core/adtfail on missing required field in comprehensioninternal/core/adtadd position for required field errorinternal/core/validateallow required fields in definitionsinternal/cuetestremove support for CUE_LONGinternal/encodingremove unused codeinternal/citrigger Unity on master as porcuepineinternal/ciremove cue-unity/unity from codereview.cfginternal/core/convermake use of reflect.Value.IsZerointernal/cifurther tidy upinternal/pkgmove pkg/internal to internal/pkginternal/cuetxtarprint error detailsinternal/core/convertsplit the cue tag commas after the last quoteinternal/ciuse go1.20.3 for releasesinternal/tdtestuse field name in default error messageinternal/core/adtfix Definition closedness bug in APIinternal/core/adtfix NotEqualOp for lists with differing lengthsinternal/diffremove unused codeinternal/core/adtfix let closedness issue with API useinternal/core/exportavoid introducing shadowinginternal/tdtestnew table-driven test packageinternal/corefail on missing required only when concreteinternal/core/adtadd wrapper for inline Vertexinternal/core/exportalways export required fieldsinternal/cifix cache evictioninternal/ciaddress review feedback from CL 551352internal/ciallow trybot workflows to be workflow_dispatch-edinternal/core/adtrequired fields checked for closednessinternal/cirefactor CI workflowsinternal/ciremove hard-codings in base packageinternal/core/adtchange addList signatureinternal/core/adtintroduce ArcNotPresentinternal/core/adtuse value array for Disjunctioninternal/core/adtspecialize injectComprehensioninternal/core/adthoist comprehension loop bodyinternal/cimove evict_caches to baseinternal/ciremove mention of matrix and runner from baseinternal/ciremove trybot from push branchesinternal/cirefactor base caching patterninternal/cidrop pullThroughProxy stepinternal/ciimprove push_tip_to_trybot defaultsinternal/ci/githubrename repo -> _repointernal/ciimport repo package once in github packageinternal/cidrop parameter from trybotDispatchWorkflowinternal/cibump GoReleaser to v1.16.2 ahead of v0.5.0 releaseinternal/cirename core -> repointernal/ciswitch to actions/setup-go@v4internal/cialways force push to trybot repointernal/ciuse unity and cuelang.org config from coreinternal/ciDRY up core based on new base defaultsinternal/ciestablish better defaults in baseinternal/cimove away from using defs in githubinternal/cimove away from using definitions in baseinternal/ciuse core directly instead of _base aliasinternal/cimove away from using defs as params in baseinternal/cicollapse gerrithub package into baseinternal/citweak gerrithub package "params" ahead of move to baseinternal/cisplit base into separate filesinternal/cirename base parameter field nameinternal/cimove pushTipToTryBot workflow to gerrithub packageinternal/cirename gerrithub #dispatchWorkflowinternal/ciremove hard-codings in gerrithub packageinternal/cimove configuration from workflows.cue to coreinternal/ciremove workflow files pre generateinternal/cisplit base into separate filesinternal/ciremove workflow files pre generateinternal/cirename gerrithub #dispatchWorkflowinternal/cimove configuration from workflows.cue to coreinternal/cirename base parameter field nameinternal/cimove pushTipToTryBot workflow to gerrithub packageinternal/cihoist dispatch keys to baseinternal/cimove workflows.cue defs to better placesinternal/cihoist cache steps to base packageinternal/ciimprove base package docsinternal/cimake our checkout step configurableinternal/cispecify githubRepositoryPath directlyinternal/cimove core._#URLPath to baseinternal/cimove core.#codeReview to baseinternal/cimove core package away from definitionsinternal/ciimprove core package docsinternal/cirefactor the way we declare workflowsinternal/core/adthoist value validationinternal/core/adthoist comprehension codeinternal/core/adtreorganize nodeContext fieldsinternal/core/adtunexport more methodsinternal/core/adtunexport VertexStatusinternal/core/adtremove state arg from Err, SetValue, and UpdateValueinternal/core/adtunexport Unifyinternal/core/adtclone arcMapinternal/ciremove the cachePost stepsinternal/cibump default of cue version to v0.5.0-beta.5internal/ciupdate base early git checks from alpha.cuelang.orginternal/core/adtallow required dynamic fieldsinternal/ciskip test cache on protected branchesinternal/core/adtimplement required fields.internal/core/adtmerge OptionalField and Field typesinternal/cibump pinned version of Go for releasesinternal/ciuse a group of cue commands for go:generateinternal/cirerun trybot workflows post evictioninternal/citidy up use of curl for GitHub API callsinternal/cido not evict caches on push to ci/testinternal/cievict workflow caches on a daily basisinternal/cibump to use ubuntu-22.04 as our linux machineinternal/ciuse actions/cache/restore for non-protected branchinternal/cireset git directory timestamps fasterinternal/cifix up modified times for all directoriesinternal/cirun long tests on linux when testing CLsinternal/cirestore git modified times after cloninginternal/core/adtuse ? in debug outputinternal/core/adtoptional field rewriteinternal/ci/gerrithubupdate comment to be clearerinternal/core/adtfinalize earlier for arcsinternal/core/adtpass member type to insertFieldinternal/core/adtremove duplicate statementinternal/core/adtexport arcType and friendsinternal/core/adtrevert fix for 2209internal/core/adtfix possible infinte loop for API usageinternal/core/adtfix regression in comparing to bottominternal/core/adtremove unnecessary checkinternal/core/adtdetect closed lists as fatal errorsinternal/core/adtsharpen condition for scalar settinginternal/cuetxtarconfigurable load.Configinternal/ciuse simpler "go get" to pull a version through the proxyinternal/cionly run release workflow on main repointernal/cido not release "zero" releases in release workflowinternal/cifix goreleaser in non-snapshot mode againinternal/cifix and test the release workflow on branchesinternal/core/adtfix 2235internal/core/adtadd tests for 2235
pkg7
pkg/encoding/jsonadd tests that needs to be fixedpkg/encoding/jsonadd more structure to testspkg/pathremove unused codepkg/netadd Path{E,Une}sape and Query{E,Une}scapepkg/toolsmall fixes to CUE docspkg/listsimply template for Ascendingpkg/listreimplement sort
tools3
tools/flowcheck cycle markertools/fixremove unused codetools/flowsupport tasks inside slices
Other24
depsupgrade to go1.20.6 for release buildsCONTRIBUTINGfix references to the old Unity repo- deduplicate content between README and CONTRIBUTING
- move doc/contribute.md to CONTRIBUTING.md
readmewarn new contributors not to use SSH auth- correct misleading phrases in documentation
specadd definition for dynamic fieldsspecvarious fixes- increase apd.Context precision from 24 to 34
- update to cockroachdb/apd v3
depsswitch to use quicktest instead of testifycodereview.cfgadd cue-unity-newdocs/tutorialrevert to using cue eval -i- update txtpbfmt to drop indirect dependency on glog
- bump golang.org/x and go-internal deps
- start using Go 1.20, drop Go 1.18
- Revert "internal/ci: move pushTipToTryBot workflow to gerrithub package"
- Revert "internal/ci: rename base parameter field name"
- Revert "internal/ci: move configuration from workflows.cue to core"
- Revert "internal/ci: rename gerrithub #dispatchWorkflow"
- Revert "internal/ci: remove workflow files pre generate"
- Revert "internal/ci: split base into separate files"
.githubclarify what we mean by "latest release"- internal/encoding/{json|yaml}: disallow non-regular fields
Downloads
Every file this release published on GitHub, with its SHA-256. Most people install CUE as Installing CUE describes, which also shows how to check a download.
Archives
| Platform | File and SHA-256 |
|---|---|
| macOS, Intel | cue_960c8d863f18b1e78c7bc5eeb6e720fe20f47ee7311b935b0bbdeeb5430ab0b0 |
| macOS, Apple silicon | cue_e5af24a5017f3e60eb0d1647744239c5e53c6e521a311c85930eba18ff1bc87a |
| Linux, x86-64 | cue_3ae7b28e12de2e0554c28d9a9eb3dd919f0640274c925ba0e36de9079af80de2 |
| Linux, Arm64 | cue_57d9517b6af3e33e7614fa755dfb9ce14c3b05195aaa835fbe8e592db3cee203 |
| Windows, x86-64 | cue_69c32671349665ec4af9b8ab7a312e870b8318bf747041c0da2b8f505ce0e2e5 |
| Windows, Arm64 | cue_c8ba01b8914da74bedbca653846c0311dcc2ed07fdb83bebacc59ba0f72c3f7e |
SHA-256 checksums for all of these: checksums.txt