v0.3.0-alpha6

cue-lang/cue Pre-release Released

A release of CUE OSS · its page on GitHub

This release is characterized by closing some significant remaining gaps in with the language specification.

There are the usual bug fixes and improvement to error messages, though.

Language

The language has now been brought closer to the spec, implementing some of the remaining gaps. There have also been some simplifications that will allow further generalizing the language down the road more easily and without introducing backwards incompatibility.

Multiple comprehensions per list

As the spec already allowed, it is now possible to include multiple comprehensions per list.

For instance:

src:    [ "John", "Mary" ]
cond: true
a: [
    for x in src { x },

    if cond { "Sasha" }
]

The list operators (concatenation and multiplication) are now also implemented in terms of comprehensions. There is a great deal of confusion about list operators (is the result open, closed, when do overlapping constraints apply?). This confusion is eliminated by writing the equivalent as list of multiple comprehensions. Our intention is to remove these operators and have comprehensions (and later queries) be the only way in which lists can be concatenated or multiplied. Of course, cue fmt will help in the transition there as usual.

Embedded scalars

Just as it is possible to write

[ #a, #b ]

#a: 1
#b: 2

at the top of a CUE file, it is now also possible to have an embedded scalar along with definitions in any struct:

x: {
    [ #a, #b ]

    #a: 1
    #b: 2
}

Originally, the top-level construct was allowed to make CUE strictly compatible with JSON. Generalizing this to any struct makes the use of imported file objects consistent with normal structs. Moreover, it turns out that this construct can be quite useful overall.

Old CUE code is not affected by this change.

Semantics of [pattern]: value fields (no change after all)

The spec recently included a change that proposed to use the JSON schema semantics for pattern constraints ([k]: v), rather than the old CUE semantics. To aid in the transition, cue fmt rewrote these fields to be enclosed in curly braces, which mimics the old semantics under these planned rules.

It has now been decided to keep the old semantics and stop rewriting old uses.

As it turns out, the old semantics was used quite a bit and was actually the majority use case. The argument previously was that the JSON schema semantics was not easily expressible in terms of the old semantics, but that the old semantics is easy to simulate with the JSON schema semantics.

Instead we now intend to allow the JSON schema semantics additionally by writing [...k]: v. The nice thing here is that any pattern which is to be matched additionally, is now always preceded by a .... It also is a nicer generalization of the syntax.

But above all, it removes the need for a potentially painful transition.

Removed integer division operators

CUE allowed integer division and remainder per the div, mod, quo, and rem operators. These were relatively rarely used and complicated the CUE syntax, formatting and other parts of various subsystems.

Moreover, they made it lexically impossible to allow indexing of the form a.3 (instead of a[3]) down the road. We are not certain if we will allow this, but allowing it makes the syntax considerably more regular and consistent. With this change, we have the option to do so in a backwards compatible way.

These operators have now been replaced with builtins. As usual cue fmt will rewrite old uses to use the builtin for some time to come. It will use the __foo variant to avoid shadowing issues. These can be manually rewritten to remove the leading underscores if necessary.

Variable argument builtins

The model for builtins, which are still underspecified in the spec, is narrowed down more. It is now possible to define variable argument builtins.

The main reasons:

  1. Variable argument builtins are quite useful in being able to extend APIs in a backwards compatible way,
  2. It allows introducing some environment dependence in a clean, intuitive and nonetheless hermetic way.

The first target was pkg/path which now supports multiple OSes (see below).

Bug fixes

Errors in nested comprehension clauses were sometimes dropped, causing a failure in a nested if clause to be silently ignored. This has now been fixed.

Other fixes includes crashes related to let clauses and bytes interpolation.

Error messages

There are various areas where error messages have been improved.

cue fmt

There are various printing bugs that were fixed. Overall the stability of fmt should have been improved notably.

API

The API got a few fixes related to backwards compatibility and should now be more like v0.2.0 where this makes sense.

pkg/path

This package has now been extended to support multiple operating systems simultaneously. Most builtins have been extended to allow an additional optional argument to indicate the OS for which the builtin is to be applied. For instance:

path.Split("foo\bar", os)

will now return a different value depending on whether os is path.Windows or path.Unix. The os argument can also be omitted, in which case it defaults the existing behavior, which is identical to path.Unix.

Note that os will not default to the currently running OS. This would make the behavior non-hermetic. The idea is that the existing injection mechanism can be used (or a small extension of it to make this specific case easier) to inject an environment-specific value.

Backwards compatibility

The cue tool is now a bit more aggressive to panic if it encounters an internal inconsistency error. In return, it now allows the user to define a CUE_DEBUG=0 environment variable to disable this. In many cases the crashes can be ignored while still getting useful results.

Not using this option and filing bugs can help improve the stability of CUE though.

Main backwards incompatibility to note:

  • removed integer division operators (now builtins). This can be fixed by running cue fmt.
  • some of the bug fixes may cause CUE files that previously succeeded erroneously to fail now.

All changes

55 changesby area

cmd3

  • cmd/cue/cmddon't bail for non-matching filese77ccb1
  • cmd/cue/cmdignore possible top-level tasksfecdd83
  • cmd/cue/cmdmore position information for field errorsbbe493a

cue9

  • cue/formatformat let clausefe73e8f
  • cue/formatpad floats with leading or trailing periods110d0bf
  • cue/loadallow ./... to load all packagesfac5d2e
  • cue/parserfix comment placement555fb73
  • cueallow multiple comprehensions in lists1c904cc
  • cuefix PathCorrection tests8872b98
  • cueimplement embedded scalars6c49cf0
  • cuemap API values to more native ADTd5177fd
  • cueremove aliases used for refactoringb687b7f

internal34

  • internal/core/adtadd Assert for debugging76ea22c
  • internal/core/adtadd methods for concreteness37293f9
  • internal/core/adtautomatic renaming41afc87
  • internal/core/adtbetter message for permanently non-concrete values2d568d3
  • internal/core/adtclean up Builtin and Validator semanticsf62bfed
  • internal/core/adtdo list artihmetic with comprehensions4db8ffb
  • internal/core/adterror message improvementscbcb701
  • internal/core/adtimprove error message for optional fieldsd0dd888
  • internal/core/adtintroduce base value type08a1652
  • internal/core/adtmake progression check an assert6de877a
  • internal/core/adtmove decimal logic into one place8b13752
  • internal/core/adtpass errors up in nested comprehensionsb8c852d
  • internal/core/compileadd integer division builtins36f2051
  • internal/core/compiledon't panic for incorrect labels9c6ded8
  • internal/core/compilefix issue in and builtin13e4af1
  • internal/core/convertallow results of math to be integerff3e32f
  • internal/core/evaladd more tests for embedding31896af
  • internal/core/evalbetter incomplete error messagesd49777f
  • internal/core/evalfix closedness issue for lists55602d9
  • internal/core/evalhoist vertex processing logic9f1fec6
  • internal/core/evalkeep semantics for [K]: Tcefe38b
  • internal/core/evaltrack fieldSets for data valuesacc35f1
  • internal/core/exportallow showing recursive errors.e7e27e0
  • internal/core/exportfix bytes printing bug039fb59
  • internal/core/exportfix crash with let comprehension export2ea30a2
  • internal/core/exportsupport byte interpolations16809ea
  • internal/core/runtimeassign first label to _.63594ef
  • internal/core/subsumetests embeded scalars0811662
  • internal/core/subsumevarious bug fixesa4d0928
  • internal/coreallow variable arg functions136e51b
  • internal/coremove equality checks from eval to adte841714
  • internal/cue/adtremove use of Default in noded174bc0
  • internal/encodingdon't clobber files on crashfa6308f
  • internal/filetpesimprove error messagesec6f95d

pkg5

  • pkg/internal/builtinuse normal formatting for builtin test resultsfb3b02e
  • pkg/path/testdataadapt Go implementationa50960c
  • pkg/path/testdatamove files to minimize diffsa2692ef
  • pkg/path/testdatastage filepath files from Goc77b9b0
  • pkg/pathactivate OS-dependent version85f8b46

Other4

  • doc/ref/spec.mdperpare for allowing a.4.f19f6f3f
  • doc/ref/spec.mdrevert to the old semantics of [k]: vf52a0ed
  • tools/fixrewrite integer division64434c4
  • tools/flowignore faulty tasks outside the rootd5ced74

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

PlatformFile and SHA-256
macOS, Intelcue_0.3.0-alpha6_Darwin_x86_64.tar.gz6899e5be9321e283bd88d8fda4c22dae0736481f8095cab8fd03bb131ebe138c
Linux, Arm64cue_0.3.0-alpha6_Linux_arm64.tar.gz17f26840a3a9053be72d5b769a121ed60d6e6148471b4495bc2b1bf07f6f9d73
Linux, x86-64cue_0.3.0-alpha6_Linux_x86_64.tar.gz65481a3d7e18860bc79f067993dbb297b1b15b802902c64ddacbf05f91e67492
Windows, x86-64cue_0.3.0-alpha6_Windows_x86_64.zip24e20c2ee44deecda10d54e25f93c28565af87cbff092c919f006595a079db49

SHA-256 checksums for all of these: checksums.txt

Install CUE