github cuelang/cue v0.3.0-alpha3

latest releases: v0.4.0, v0.4.0-rc.1, v0.4.0-beta.2...
pre-release3 years ago

This release mainly introduces per-file inclusion based on tags, bug fixes for bugs introduced in the new evaluator, and tests to close issues raised on the old evaluator that are now verified to be fixed.

Language extensions

Attribute declarations in preamble

Attribute declarations are now allowed before the package clause and import declarations. This is used to implement file-wide inclusion.

Any scalar now allowed in interpolations

This includes boolean and byte values. Boolean values are represented as their JSON value. In string interpolations, bytes are converted to valid UTF-8 by replacing the maximal subpart of ill-formed subsequences with a single replacement character (W3C encoding standard).

Whole file inclusion

CUE now allows files to be conditionally included in a build. To conditionally include a file in a CUE program, one can now write:

@if(prod)

package acmecorp

and use the -t prod flag to cause this file to be included. The expression can be any valid CUE expression using only boolean operators and boolean values.

See cue help injection for more details.

Closedness rewrite

A large number of bug fixes related to an incorrect “field not allowed” error are now in. The algorithm for closedness has been significantly simplified and streamlined based on the benefit of hindsight.

Note that one may still have a misleading “field not allowed” error if a field is disallowed in one disjunct and allowed in another, but where there is another field in conflict. Right now only one of the errors is reported.

CUE API

New evaluator

The CUE API is now moved to the new evaluator.

Package dependencies

Builtins now live in their own package and are no longer copied into the cue API. This was part of the effort to break the implementation into logical pieces, instead of having one large package.

This has the additional advantage that each builtin package now only lives in its own directory and is not copied. This makes maintenance easier and also removes some of the limitations imposed by the old implementation.

Unfortunately, this means that custom loader implementations (ones that do not use cue/load for loading packages) will have to include

import 	_ "cuelang.org/go/pkg"

somewhere in the package to trigger linking in the builtin packages.

cue tool

This release also marks the first steps of moving functionality from the cue command line tool to the CUE APIs. The intention is that the cue tool will be mostly a wrapper around core functionality present in the API. Other tooling could provide a different “view” without being second-class citizens in the ecosystem and while providing consistency between such tools.

The first step towards this is the injection mechanism. The existing parts of this were moved to the cue/load package. The new file inclusion functionality, meanwhile, was directly implemented in cue/load.

The next step will be to move non-CUE file support and packaging mechanisms to cue/load and friends. Then next up is the tooling layer, starting with an API for dependency analysis.

Next steps

There are two outstanding issues on the table to come to a beta release:

Disjunctions

Although there are no known semantic bugs related to disjunctions, the code needs some restructuring to improve error messages and to fix some performance issues. This is slated for the alpha4 release.

Structural cycles

There are still some bugs outstanding related to structural cycles. The plan is to address all of these in an alpha5 (or possibly beta) release.

Backwards compatibility

Go version

Support for go1.12 was dropped. In exchange, this release is verified to build with Go’s tip (1.16).

CUE API

The CUE API has now fully been moved over to use the new evaluator. The old evaluator code has been removed.

  • cue.Merge: the purpose of Merge is to unify the underlying instances as data. It now no longer also unifies definitions. Bug fixes in closedness exposed this previously unnoticed oversight.

Custom loader implementations (ones that do not use cue/load for loading packages) will have to include

import 	_ "cuelang.org/go/pkg"

somewhere in the package to trigger linking in the builtin packages.

Language changes

CUE code that previously expected a boolean or bytes value substituted in a string interpolation to fail my now break.

cue cmd

Commands that operate on multiple instances simultaneously (e.g. cue cmd foo ./...) can no longer reference definitions in the underlying commands. For more info see cue.Merge in the API section.

Changelog

d69319c all: add missing copyright
4c10692 all: fix four previously ignored errors
6c27cef ci: drop go1.12 add go1.15
c3f30d8 ci: name dispatch workflow differently to default branch push workflow
1c54297 cmd/cue/cmd: fix get go package handling
1e8906a cmd/cue/cmd: move injection mechanism to cue/load
faf617c cmd/cue/cmd: verify issue 236 is fixed
e71970c cmd/cue/cmd: verify issue 322 is fixed
8776561 cmd/cue/cmd: verify issue 425 is fixed
ba5708b cmd/cue: get go: add --package flag
1a9b88d cmd/cue: get go: use constant.Value.ExactString to extract constant
f25c04d cmd/help: fix example in doc
089f461 cue/load: add support for build tags
bc101b3 cue/load: add tool and test files to BuildFiles if requested
20c637a cue/load: relax places where @tag is allowed
bd3dd75 cue/load: rewrite pre-resolved files after injection
c264475 cue/parser: allow attributes before package and import clauses
4cce6c4 cue: apply wrapping to all errors in list
d2fdbf0 cue: clean up handling of preamble declarations
80e70b9 cue: fix instance error handling
c76a530 cue: implement fill in terms of Value.Fill
845df05 cue: make internal cue port main API implementation
abce145 cue: move to external builtin packages
ce28b20 cue: prepare to hoist builtin code
9acd624 cue: prepare to hoist builtins, step 2
40a6bcd cue: remove dead code
6f84d11 deps: upgrade to github.com/rogpeppe/go-internal v1.6.1
edea6f3 doc/ref/spec.md: fix len count for structs
043c534 doc/ref/spec: clarification on cycles
dd0fa88 doc/ref/spec: consider definitions for closedness
c7c14fd doc/tutorial/kubernetes: remove a duplicate kind field
e3a03a1 internal/core/adt: exclude definitions in data conversion
db18b37 internal/core/adt: prevent nil interface bug for Source
f5fa009 internal/core/adt: remove all closedness IDs in ToData
30ca062 internal/core/adt: support interpolation of bytes and bool
df01042 internal/core/compile: better error message for user-defined errors
d55e2b5 internal/core/eval: allow lists resulting from dependent expressions
c72ce5d internal/core/eval: fix empty data vertex bug
0b57e43 internal/core/eval: fix interpolation of numbers
e0c19d1 internal/core/eval: fix issue 507
304b02e internal/core/eval: nested comprehension fix
62528c3 internal/core/eval: rewrite of closedness algorithm
dc2401c internal/core/eval: verify issue 258 is fixed
ddd99d5 internal/core/eval: verify issue 293 is fixed
ea5d964 internal/core/eval: verify issue 295 is fixed
480e1a1 internal/core/eval: verify issue 299 if fixed
541bf03 internal/core/eval: verify issue 306 is fixed
5905c22 internal/core/eval: verify issue 332 is fixed
121ace7 internal/core/eval: verify issue 342 is fixed
07ce2f6 internal/core/eval: verify issue 353 is fixed
4ecec98 internal/core/eval: verify issue 370 is fixed
fbf9de3 internal/core/eval: verify issue 398 is fixed
c6ade67 internal/core/export: fix bug 473
b9b2c54 internal/core/export: better handling of generated CUE
1e1fe6f internal/core/export: handle scalar values in adt.Vertex
67d1d42 internal/core/export: suport default picking
df9468e internal/core/export: verify issue 349 is fixed
60c207f internal/core/runtime: collect errors for all files in resolve
a6ce869 internal/core: finalize list in slice
148f67a internal/core: fix incorrect error handling
3d863fc internal/core: move CloseID from Environment to Conjunct
bf882b0 pkg/internal: copy cue builtin code to separate package
dda7de4 pkg/math: fix issue 418
4f4b7a3 pkg/tool/file/append: create file if none exists.
c8a4514 pkg/tool/http: fix handling of errors
248794e pkg: generate per-directory tests from builtin_test.go
1bcb73a update go-internal to pull in fix for Go 1.16

Don't miss a new cue release

NewReleases is sending notifications on new releases.