v0.16.0-alpha.2

cue-lang/cue Pre-release Released

A release of CUE OSS · its page on GitHub

Changes which may break some users are marked below with: ⚠️

Language

As a reminder, we have two ongoing language experiments since v0.15; a replacement for struct embedding and a rework of aliases. Please give these a try and report any issues or feedback!

The new try experiment

This experiment adds a try clause in comprehensions as well as the use of ? in field selectors. This addition to the language intends to provide a more concise syntax for handling optional fields without the risk of unintentionally swallowing errors.

You can try this experiment by following our how-to guide. For more information, see the proposal on GitHub and the spec change patch.

The new else comprehension clause

This change adds an optional else clause for CUE modules targetting the language version v0.16.0 or later. With this addition to the language, an if or for comprehension may be followed by an else clause which triggers when the comprehension produces zero values.

Note that this feature is not an experiment; it is available to any CUE module targetting the language version v0.16.0 or later.

You can try this feature by following our how-to guide. For more information, see the full patch which includes the changes to the spec, or read the pre-release version of the language spec.

Evaluator

A number of changes were made to improve support for using cue.Values concurrently; see Issue #2733 for more details and ongoing progress.

A number of panics and other bugs in the evaluator which were reported since v0.15.0 have been fixed; thank you to all who reported these.

cmd/cue

The global --verbose and --trace flags have been moved to the cue get go and cue trim commands respectively, as they were the only ones actually using those flags, and this could be confusing to users.

Fix a bug where loading ./...:pkgname could lead to loading directories with zero CUE files as instances, which could cause poor performance for CUE packages with multiple parent directories.

LSP server

Code Actions: two code actions are now provided, Add surrounding struct braces and Remove surrounding struct braces, which convert between

a: b: c

and

a: {
	b: c
}

with the cursor on b.

Initial LSP support for editing embedded JSON files. This feature provides completions and hover-docs when editing JSON files which are embedded into CUE via the @embed attribute. A teaser video is available on YouTube. Support for embedded YAML files will appear soon.

Several bug fixes, including better behaviour for files and directories with spaces; improvements for value aliases (foo: L=x); LSP rename now provides placeholder text.

See our Getting Started wiki page for instructions on how to set it up with your editor.

Please report any bugs or missing features you encounter via the Issue tracker or via the #lsp channels on Discord or Slack.

Encodings

Add support for encoding YAML tags like key: !Custom value by using CUE attributes like key: "value" @yaml(,tag="!Custom").

Standard library

The net package adds CompareIP to compare two IP addresses, which can be useful for computing with IP ranges.

The net/http package adds Serve as an experimental API to listen on a port and serve HTTP requests.

The tool/file package adds Symlink to create symbolic links.

Go API

cue/ast gains the NewPredeclared and Ident.IsPredeclared to mark and detect identifiers referencing predeclared names like error or int rather than fields which may shadow those names in the current scope.

⚠️ cue/token.Compare now sorts absolute paths before relative ones, to ensure consistent behavior between Unix-like systems and Windows.

⚠️ The long-deprecated and hidden cue.Instance.Eval method is now removed.

All changes

104 changes since v0.16.0-alpha.1by area

all6

  • allstart using "else" in comprehensions@mvdan3f2f654
  • alluse reflect.TypeAssert in three more places@mvdan58cbd0c
  • allre-apply go fix -any=false ./... after Go version bump@mvdan8579c46
  • allapply the straightforward Go 1.25 or later cleanups@mvdane834a18
  • alltest and release on Go 1.26, require Go 1.25 or later@mvdan0dc0eac
  • allgo fix -any=false ./...@mvdan3d3f74b

cmd10

  • cmd/cueadd and unskip tests for invalid task type errors@mvdandb4afc1
  • cmd/cue/cmdadd test coverage for absolute packages with cue cmd@mvdanf5e266a
  • cmd/cuedeflake cue_after test@rogpeppe4504db0
  • cmd/cue/cmdadd failing test for issue #4202@mvdan0a4a11a
  • cmd/cuerewrite help fmt@mvdan0fa24af
  • cmd/cuealter flag behavior based on the command name@mvdanbc5bd8f
  • cmd/cuedrop --verbose and --trace as global flags@mvdan92afa2e
  • cmd/cuemap constants by go/types.Type directly@mvdandac4e90
  • cmd/cuetest that cue fmt also formats files with no package clause@mvdand65c829
  • cmd/cuerewrite help vet@mvdan9488f0c

cue18

  • cue/testdataupdate stats for comprehensions/try.txtar@mvdan20c1149
  • cue/buildintegrate identifier resolution into Complete@mpvl1aeb33e
  • cue/ast,cue/ast/astutiladd NewPredeclared and IsPredeclared for builtin references@mpvl8405422
  • cue/loadimprove error for major-only version packages outside a module@mvdan7675369
  • cueclarify that Schema is only useful for Value.Subsume@mvdanbb18d7b
  • cue/loaddo not load non-CUE directories as instances@rogpeppea4d2a6f
  • cue/loadadd test case for non-package directories@rogpeppe028411e
  • cue/internalMake ToFile optionally preserve StructLits@cuematthewec3e289
  • cue/ast,cue/ast/astutiladd Predeclared sentinel for builtin references@mvdan42cc85f
  • cue/ast/astutilfix false positive in label expression check for let clauses@mvdana93bcc1
  • cue/testdataadd regression test for issue #4203@mvdane3eb948
  • cue/errorsavoid duplicate path in error list formatting@mvdan487c072
  • cue/testdata/builtinsadd test for error() with erroring interpolation@mvdana6070c8
  • cue/testdata/disjunctionsadd regression test for value alias in disjunction@mvdan0c9ed36
  • cue/testdata/cycleadd regression test for issue 4244@mvdaneb2c57c
  • cue/tokensort absolute positions before relative ones@mvdan46c1f9d
  • cueremove Instance.Eval@mvdan60c0505
  • cuepoint out cue/format exists in the godoc@mvdanba2ce99

encoding3

  • encoding/gocodefix test@rogpeppe98ca6e3
  • encoding/yamladd support for YAML tags via @yaml(,tag) attribute@jonas-meyerb1a58bd
  • encoding/jsonextract PatchExpr to internal/encoding/json@cuematthewe5bfcda

internal35

  • internal/core/exportfix self-referential lets for recursive definitions@mvdanc257634
  • internal/core/compileavoid double error for invalid optional references@mpvlc1be2bb
  • internal/core/adtadd regression test for error() in pattern constraint keys@mvdan50a0a5e
  • internal/core/adtfix structural cycle hang with braced selectors@mvdan36702fd
  • internal/core/depfix stack overflow on recursive definitions in dep analysis@mvdan0b49a54
  • internal/core/dep,internal/core/exportfix stack overflow on recursive definitions@mvdand0e2ab6
  • internal/coreremove import path to instance mapping@rogpeppeb3d9ffc
  • internal/ciexplicitly set contents permission@myitcv7cde504
  • internal/core/adtimplement try expressions@mpvlf2e8299
  • internal/core/adtfix else clause duplication in comprehension field splitting@mvdan40356ab
  • internal/astinternalomit ILLEGAL tokens in debug print@mpvl23736eb
  • internal/cidisable checkout persist-credentials by default@myitcv069eac9
  • internal/core/exportfix panic in relPathLength for BinaryExpr@mvdan788eeed
  • internal/core/exportavoid let name collisions with dependency fields@mvdanf2b697a
  • internal/core/exportadd failing test for issue #4221@mvdanb690442
  • internal/core/adtfix undefined field in comprehension with structural cycle@mvdan225a1c4
  • internal/core/adtfix panic in memory reclamation@mvdan355d6fd
  • internal/core/adtadd else clause to comprehensions@mpvl9e2dec3
  • internal/core/exportfix hidden identifier renaming in for clauses@mvdan2fea4bc
  • internal/core/exportadd failing test for issue #4254@mvdanc53993e
  • internal/lspimplement ConvertFromStruct code action@cuematthewf68f686
  • internal/cibump actions/checkout and cue.dev/x/githubactions@mvdanf4d1d5a
  • internal/core/runtimeadd lock protection to loaded map@mpvl6451728
  • internal/core/adtfix race condition in Vertex.Default()@mpvl854a5b7
  • internal/core/adtuse thread-safe WeakMap for regexp caching@mpvlc7797c1
  • internal/lspmodel embedded files as packages@cuematthewfa8946f
  • internal/lspFileEvaluatorForURI returns lsp/cache.File@cuematthewdbf3293
  • internal/core/compilefix operator precedence in error() builtin@mvdan70b3f3e
  • internal/core/adtfix value alias resolution in disjunctions@mvdanb053ad5
  • internal/core/adthandle EqualOp in SimplifyBounds@mvdan0813460
  • internal/lspimplement ConvertToStruct code action@cuematthewc45f72d
  • internal/core/adtrefine cycle handling in LetReference.resolve@mvdan3e1e745
  • internal/ciallow steps to influence job permissions@myitcv839f03d
  • internal/cifix release workflow@myitcv9e34d67
  • internal/ciuse new registry-login-action@myitcvf595566

lsp13

  • lsp/evalAdd support for try-clauses and optional path components@cuematthew62de631
  • lsp/fscacheignore ASTs which have no absolute positions@cuematthew2585b3b
  • lsp/cacheexpand completion range of fields in json for double-quotes@cuematthewb1c63da
  • lsp/cachecompletions must not return null items list@cuematthew75ee97a
  • lsp/evalfix field-value aliases@cuematthew29d8be4
  • lsp/evaladd test to show bad behaviour of aliases@cuematthew3e6bee7
  • lsp/serverforce-load all packages for completions within embedded files@cuematthew5eb5ed9
  • lsp/evalprocess field attributes and specialise queries for embeds@cuemattheweb192c6
  • lsp/fscacheread json and yaml files as CUE@cuematthew6825394
  • lsp/cacherework package dirtying and reloading@cuematthew22fff24
  • lsp/evalchange eval constructor to take Config struct@cuematthew3cd3244
  • lsp/fscachecorrect path components@cuematthew44a543b
  • lsp/cacheprovide placeholder for PrepareRename@cuematthew049d6e1

pkg7

  • pkg/list/testdataadd regression test for issue #4171@mvdane977cfa
  • pkg/tools/httpremove valueMu mutex from http.Serve@mpvl95ba1d2
  • pkg/tools/httpexperimental implementation of http.Serve@mpvl0badd6d
  • pkg/netadd CompareIP@mvdan174a8b9
  • pkg/encoding/openapisupport marshalSchema builtin for openAPI@mpvl66ea772
  • pkg/tool/fileadd Symlink@sprat6618a6f
  • pkg/pathremove osInfo.HasPrefix@mvdan516099a

tools3

  • tools/flowskip phantom tasks from eliminated conditional branches@mvdan7fb912e
  • tools/fixuse ast.Predeclared to avoid shadowing in value alias conversion@mvdan08a7ec3
  • tools/fixadd tests for value alias conversion when "self" is in scope@mvdan3dacb0c

Other9

  • update all dependencies@mvdan9fb0173
  • doc/specuse "custom errors" instead of "user errors"@myitcvbaf8302
  • tweak Claude's allow and deny settings further@mvdanef6bb80
  • _scriptsadd OpenSpec support for AI-assisted development@mpvl6a78eff
  • golps/protocolintroduce DocumentURI.Path method@cuematthewf04e0fb
  • gopls/protocolrename DocumentURI.Path to DocumentURI.FilePath@cuematthewd8eca4a
  • interpreter/embedprepare embed for extension@cuematthewa95414a
  • integration/workspaceadd test showing bad behaviour@cuematthewc164d8f
  • add go tool cue and xargs as allowed Claude commands@mvdan4b495fa

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_v0.16.0-alpha.2_darwin_amd64.tar.gz5f87d6689dd6f2780331d3bdcd3cc82d11d4310a2a6b97d75cd4876b5786a3d1
macOS, Apple siliconcue_v0.16.0-alpha.2_darwin_arm64.tar.gz0b14d69979cb5f846d3e1aeeffc976ba63b5f4de3ace3d2e13001feadea87cad
Linux, x86-64cue_v0.16.0-alpha.2_linux_amd64.tar.gz419688b77f32b00dba767d6778c730c1333b56f37ea52c4b87f808047283286d
Linux, Arm64cue_v0.16.0-alpha.2_linux_arm64.tar.gza56b5d2a61edf468dfd508fbd5b52375a1685e3cef9cc8a612049f172da56937
Windows, x86-64cue_v0.16.0-alpha.2_windows_amd64.zipdd89b28aee5258c0cb22cf579e091e8790e1c9845967c18a18a41af36e01fc6d
Windows, Arm64cue_v0.16.0-alpha.2_windows_arm64.zip9bdd930c190f0a20690218348a5f288c6dd641b25710073f5905b6ea49782fab
Install CUE