Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cue: Value needs a method to finalize a value #3289

Open
myitcv opened this issue Jul 12, 2024 · 0 comments
Open

cue: Value needs a method to finalize a value #3289

myitcv opened this issue Jul 12, 2024 · 0 comments
Labels
FeatureRequest New feature or request

Comments

@myitcv
Copy link
Member

myitcv commented Jul 12, 2024

Is your feature request related to a problem? Please describe.

Consider the following code:

-- go.mod --
module mod.example

go 1.22.3

require cuelang.org/go v0.9.2

-- main.go --
package main

import (
	"fmt"

	"cuelang.org/go/cue/cuecontext"
)

func main() {
	ctx := cuecontext.New()
	v := ctx.CompileString(`{a:"a"} | {a:"a",b!:string}`)
	fmt.Printf("%v\n", v)
}

As expected this gives:

{
        a: "a"
} | {
        a:  "a"
        b!: string
}

i.e. v is incomplete.

What I would like is a method on cue.Value that allows me to finalise v to give a cue.Value which would render as:

{
        a: "a"
}

Noting that at the time of writing #3285 is a bug. But even if that bug were fixed, there is no method on cue.Value that I can call with cue.Final to say "there is nothing more to come".

Describe the solution you'd like

A method on cue.Value that accepts cue.Final() and returns a finalised cue.Value.

Describe alternatives you've considered

Nothing particularly elegant, other than going to and from CUE source.

Additional context

n/a

@myitcv myitcv added the FeatureRequest New feature or request label Jul 12, 2024
@myitcv myitcv changed the title cue: Value needs a method to finalise a value cue: Value needs a method to finalize a value Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant