Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

How to use cuecontext.Context to compile definitions and concrete values in multiple passes #988

Answered by mpvl
yannk asked this question in Q&A
Discussion options

You must be logged in to vote

The Context does not retain anything. The context just holds indices for mapping field names, builtins, etc. But there is no retention otherwise.

However, you can pass a "scope" which is used to resolve all unresolved identifiers:

	ctx := cuecontext.New()

	def := ctx.CompileString(`
#Def: {
	id: string
    version: string
}`)

	val := ctx.CompileString(`
v: #Def & { id: "hi" }
	`, cue.Scope(def)) // USE def to RESOLVE UNRESOLVED IDENTIFIERS, LIKE #Def

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@yannk
Comment options

@myitcv
Comment options

Answer selected by yannk
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants