v0.3.1
This release contains several bug fixes, API additions, some API deprecations, and a language addition. One of the bug fixes may lead to unexpected behavior (see below).
Backwards Incompatible Bug Fix
One common use case of cmd/cue involves combining CUE and non-CUE files. Consider the following example:
// check.cue
package check
map: {for n in nodes {"\(n.name)": n}}# data.yaml
nodes:
- name: bar
parent: foo
- name: baz
parent: fooWith v0.3.0 and earlier, cue eval would happily combine these two files:
$ cue eval data.yaml check.cue
map: {
bar: {
name: "bar"
parent: "foo"
}
baz: {
name: "baz"
parent: "foo"
}
}
nodes: [{
name: "bar"
parent: "foo"
}, {
name: "baz"
parent: "foo"
}]But cue vet would complain:
$ cue vet data.yaml check.cue
map: reference "nodes" not found:
./check.cue:3:16cue vet is actually correct here. Identifier resolution should only happen across files that belong to the same package: non-CUE files are equivalent to a CUE file without a package clause or an anonymous package clause (package _), hence cue eval should really fail in this instance.
v0.3.1 makes cue eval and other commands consistent with cue vet. This was deemed a sufficiently breaking change to warrant its own release.
The fix in this case is to define nodes in the scope of package check:
// check.cue
package check
nodes: _
map: {for n in nodes {"\(n.name)": n}}at which point cue eval succeeds as before.
An upcoming change will also ensure this condition of identifier resolution is satisfied for all non-package CUE file arguments.
API changes
The cue.Selector model has been extended to allow querying optional fields and arbitrary elements.
Deprecations
The following methods of Value have now been deprecated:
FieldByName
Elem
Template
Really, you should only need LookupPath for your lookup needs. For the most part, these old methods have been reimplemented using the new API.
Also, updated the doc that one really, really should not use Merge.
If you are a user of the API we strongly recommend running staticcheck: it will raise errors where you are using deprecated parts of the API.
Language Additions
CUE now allows parenthesized expressions as labels. This is not (yet) published in the spec, but part of the query proposal. So "\(x)": foo, where x is a string, may now be written as (x): foo.
All changes
13 changesby area
cue10
cue/astallow parentheses as labelscue/buildremove unused Scope fieldcuedeprecate Value.Elem and Value.Templatecuedeprecate Value.FieldByNamecuemove LookupPath to querycueremove error type aliasescueresolve identifiers in an ast.Expr for FillPathcueseparate closedness for lists and structscuesupport optional field lookup in LookupPathcueupdate Merge comment to REALLY NOT USE IT
Other3
cmd/cue/cmdallow "exec" in commands for TestXinternal/coredon't resolve values into anonymous packagesinternal/difffix printing and top-level diffs
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_c98e3f139418325f7b33e209cd1c41013c77270349225515e328a2918beaefb1 |
| Linux, x86-64 | cue_a63533b74708c57e325ccfbefd717876205cb64d67166b6de2a27f5408577825 |
| Linux, Arm64 | cue_a1e7f1f7f84a6d3df4532b5197c4d76ced37b2889505f88b8760d92c57a05f02 |
| Windows, x86-64 | cue_23e7e57021a921cc5fb1d9a23dea4d430766e23e628e6ba7099f0f5ed39dc82f |
SHA-256 checksums for all of these: checksums.txt