github cue-lang/cue v0.3.0-alpha4
Language refinements and fixes

latest releases: v0.9.0-alpha.4, v0.8.2, v0.9.0-alpha.3...
pre-release2 years ago

This is a relatively small release. But given that it contains some significant bug fixes and performance improvements, it seemed useful to get these out sooner.

This also

Closedness refinements

The rules surrounding closedness have been further clarified in the spec where this was previously ambiguous. Most notably, it was previously unclear whether B.b in

#A: {a: int}

B: {
    #A
    b: c: int
}

should be closed or not. This is now clarified to it not being closed. In other words, fields added alongside an embedded definition that were not part of the original embedding are not closed automatically.

This does not change the current behaviour.

There was also a bug fix related to closing structs that could leave struct open if they were referenced through a selector path like #A.b, where the reference to #A failed to trigger a close.

There remains one known gap in the implementations compared to the spec: embedding a closed struct will currently cause the field to be closed, whereas the spec says that the struct in which it is included should already be closed. This will be a backwards-incompatible change.

field not allowed error

As far as is known, aside from the spec deviation mentioned above (which is somewhat esoteric), there are no more known deviations that result in a spurious error of this kind.

There is, however, one known case where this error seems to appear erroneously. Consider the following:

#a: {b: int} | {}
b: #a & {b: string}

This may still result in a “field b not allowed” error. The problem is that the error reporting around disjunctions is still lacking. What happens is that only the error of one of the failed disjuncts is reported. In this case it fails on the first disjunct (as int != string) and the subsequently fails on the second, which doesn’t allow b. As only one of the errors is reported, it may appear that it fails on the first disjunct, which is just confusing.

The intention is to considerably improve disjunction errors soon. In the meantime, the added position information for conflict errors will hopefully help a hand to disambiguate such errors.

let clauses are now allowed in comprehensions

This has been a part of the spec for a long time, but now has finally been implemented.

... anywhere in struct

This was already allowed by the spec, compiler, and evaluator, but now is also allowed by the parser.

Simple string literals now allowed as selector

Another thing that has been allowed by the spec for a while is the use of string literals as selectors. So a.”foo”.bar is now allowed. Only single-line strings without interpolations are allowed at the moment (as per the spec).

Command line tool

cli.Ask

This is now supported.

Error reporting

Error reporting has been improved further. Most notably, positions for conflict errors (as resulting from 3 & 4), now have positions added and should be on par with v0.2.2. This also adds the fundamentals for adding richer position notation.

Performance

This release fixes one big performance issue, which could lead to exponential runtime for disjunctions. This can have a big impact for many configurations. For one user, it reduced the running time from 5 hours to less than 2 seconds.

As part of this fix, we now introduced a benchmark suite.

There are tons of significant performance improvements still possible, so this is not the last of it.

Notable Bug fixes

String handling

CUE used to piggyback on Gos strconv.Quote` for quoting strings. This was not ideal, as CUE and Go strings are not the same. It also resulted in some bugs. This is now fixed. This results in better string formatting overall.

Handling of files named -

The cue command line tool sometimes hung when a directory contained a file named -. This is now handled.

Yaml version

Until now, CUE would output YAML in version 1.2 and read it in version 1.1. And it seems that the “right thing to do” is to implement version 1.2 these days. This has now provisionally been fixed to read it mostly as version 1.2. A more proper implementation would be to replace internal/third_party/yaml to use the yaml.v3 package.

This means, for instance, that the value no is now treated as a string instead of the boolean value false. (And thus the demo on cuelang.org will have to be replaced.)

Message-level options in Protobuf

Handling of message options in .proto files would previously fail. They are now translated into declaration options in CUE with the format: @protobuf(option name=value).

Backwards compatibility

YAML

As YAML 1.2 is not backwards compatible with YAML 1.1, inputs to CUE that relied on a YAML 1.1 interpretation may now yield different results.

Closedness rules

The refinement of the rules of closedness are largely backwards compatible (and what is not is not yet implemented), but some of the bug fixes may give slightly different results nonetheless.

Changelog

8ad07fa Readme.md: remove Go Report Card
2ac4d85 cue/format: indent multiline string literals based on context.
c886094 cue/literal: implement CUE-specific quoting
11b507c cue/load: don't hang on files named -
6354c40 cue/parser: allow ... anywhere in struct
241c5bf cue/parser: allow let clause in comprehension
80f0bee cue/parser: better error message for old-style definitions
732b6d5 cue/parser: support string selector labels
e9286f0 doc/ref/spec.md: fix builtin func
ff306b7 doc/ref/spec.md: fix spec bug and broken link
15e8a05 doc/ref/spec.md: refinement of closedness
65468d5 doc/tutorial/kubernetes: update import
3af2683 encoding/protobuf: parse message options
d23402c internal/core/compile: fix alias resolution bug
742593f internal/core/compile: fix hidden definition bug
da69dc0 internal/core/eval: ... does not apply to defintions
0eb7cc5 internal/core/eval: add more positions to conflict errors
3914ef8 internal/core/eval: check for nil pointer
03fa5a8 internal/core/eval: fully evaluate nested unification
f0df4df internal/core/eval: performance: unify an arc only once per node
1fdc02a internal/core/eval: simplify validators upon evaluator
1c29042 internal/third_party/yaml: drop support for non-standard scalars
5bfe37d pkg/tool/cli: support ask task

Don't miss a new cue release

NewReleases is sending notifications on new releases.