...

Text file src/cuelang.org/go/internal/core/export/testdata/main/let.txtar

Documentation: cuelang.org/go/internal/core/export/testdata/main

     1# Issue #590
     2
     3-- in.cue --
     4let X = 1 + 1
     5#Foo: X
     6-- x.cue --
     7x: string
     8
     9let Y = x
    10y: Y
    11-- y.cue --
    12x: "foo"
    13
    14// Note: although syntactically the same, this is a different let clause than
    15// the one from before and thus will be renamed.
    16// Issue #590
    17let Y = x
    18y: Y
    19-- issue593.cue --
    20cfgs: [for crd in ["one", "two"] {
    21	metadata: {
    22		name: crd
    23	}
    24}]
    25for cfg in cfgs {
    26	let filepath = "kind-\(cfg.name)"
    27	files: {
    28		"\(filepath)": {
    29			patches: cfg
    30		}
    31	}
    32}
    33-- for.cue --
    34comprehension: {
    35	for cfg in [{a: "one"}] {
    36		let filepath = "kind-\(cfg.name)"
    37		"\(filepath)": {
    38			patches: cfg
    39		}
    40	}
    41}
    42-- scope.cue --
    43scoped: {
    44	_args: required: 1
    45	direct: {
    46		let Args = _args
    47		a: Args.required
    48	}
    49	embed1: {
    50		let Args = _args
    51		a: {Args.required}
    52	}
    53	embed2: {
    54		let Args = _args
    55		a: {{Args.required}}
    56	}
    57	list: {
    58		let Args = _args
    59		a: [Args.required]
    60	}
    61	listStruct: {
    62		let Args = _args
    63		a: [{a: Args.required}]
    64	}
    65	listEmbed: {
    66		let Args = _args
    67		a: [{Args.required}]
    68	}
    69}
    70-- incomplete.cue --
    71complete: {
    72	let A = run.a
    73	x: "a \(A) z"
    74	run: {
    75		a: "foo"
    76	}
    77}
    78incomplete: a: {
    79	x: "a \(run.a) z"
    80	run: {
    81		a: string
    82	}
    83}
    84incomplete: b: {
    85	let A = run.a
    86	x: "a \(A) z"
    87	run: {
    88		a: string
    89	}
    90}
    91incomplete: c: {
    92	{
    93		let A = run.a
    94		x: "a \(A) z"
    95		run: a: string
    96	}
    97	{
    98		let A = run2.a
    99		x2: "a \(A) z"
   100		run2: a: string
   101	}
   102}
   103incomplete: d: {
   104	let A = run.a
   105	x: "a \(A) z"
   106	run: a: string
   107} & {
   108	let A = run2.a
   109	x2: "a \(A) z"
   110	run2: a: string
   111}
   112
   113unresolvedDisjunction: {
   114	#TypePrimitive: {
   115		_args: {
   116			required: bool
   117		}
   118		let Args = _args
   119
   120		{"*": {}} |
   121		{"bool": #TypeBool & {_args: required: Args.required}}
   122	}
   123
   124	#TypeBool: {
   125		_args: required: bool
   126		let Args = _args
   127
   128		if !Args.required {
   129			// `default` sets the default value.
   130			default: bool | null
   131		}
   132	}
   133}
   134-- out/definition --
   135
   136let X = 1 + 1
   137let Y = x
   138let Y_1 = x
   139{
   140	cfgs: [for crd in ["one", "two"] {
   141		metadata: {
   142			name: crd
   143		}
   144	}]
   145	for cfg in cfgs {
   146		let filepath = "kind-\(cfg.name)"
   147		files: {
   148			"\(filepath)": {
   149				patches: cfg
   150			}
   151		}
   152	}
   153}
   154comprehension: {
   155	for cfg in [{
   156		a: "one"
   157	}] {
   158		let filepath_1 = "kind-\(cfg.name)"
   159		"\(filepath_1)": {
   160			patches: cfg
   161		}
   162	}
   163}
   164#Foo: X
   165complete: {
   166	let A = run.a
   167	x: "a \(A) z"
   168	run: {
   169		a: "foo"
   170	}
   171}
   172scoped: {
   173	_args: {
   174		required: 1
   175	}
   176	direct: {
   177		let Args = _args
   178		a: Args.required
   179	}
   180	embed1: {
   181		let Args_1 = _args
   182		a: Args_1.required
   183	}
   184	embed2: {
   185		let Args_2 = _args
   186		a: Args_2.required
   187	}
   188	list: {
   189		let Args_3 = _args
   190		a: [Args_3.required]
   191	}
   192	listStruct: {
   193		let Args_4 = _args
   194		a: [{
   195			a: Args_4.required
   196		}]
   197	}
   198	listEmbed: {
   199		let Args_8 = _args
   200		a: [Args_8.required]
   201	}
   202}
   203x: "foo"
   204incomplete: {
   205	a: {
   206		x: "a \(run.a) z"
   207		run: {
   208			a: string
   209		}
   210	}
   211	b: {
   212		let A_1 = run.a
   213		x: "a \(A_1) z"
   214		run: {
   215			a: string
   216		}
   217	}
   218	c: {
   219		let A_2 = run.a
   220		let A_3 = run2.a
   221		x:  "a \(A_2) z"
   222		x2: "a \(A_3) z"
   223		run: {
   224			a: string
   225		}
   226		run2: {
   227			a: string
   228		}
   229	}
   230	d: {
   231		let A_4 = run.a
   232		let A_32 = run2.a
   233		x:  "a \(A_4) z"
   234		x2: "a \(A_32) z"
   235		run: {
   236			a: string
   237		}
   238		run2: {
   239			a: string
   240		}
   241	}
   242}
   243unresolvedDisjunction: {
   244	#TypePrimitive: {
   245		let Args_9 = _args
   246		{
   247			"*": {}
   248		} | {
   249			bool: #TypeBool & {
   250				_args: {
   251					required: Args_9.required
   252				}
   253			}
   254		}
   255		_args: {
   256			required: bool
   257		}
   258	}
   259	#TypeBool: {
   260		let Args_B = _args
   261		_args: {
   262			required: bool
   263		}
   264
   265		if !Args_B.required {
   266			// `default` sets the default value.
   267			default: bool | null
   268		}
   269	}
   270}
   271y: Y & Y_1
   272-- out/doc --
   273[]
   274[comprehension]
   275[comprehension filepath]
   276[X]
   277[#Foo]
   278[complete]
   279[complete A]
   280[complete x]
   281[complete run]
   282[complete run a]
   283[incomplete]
   284[incomplete a]
   285[incomplete a x]
   286[incomplete a run]
   287[incomplete a run a]
   288[incomplete b]
   289[incomplete b A]
   290[incomplete b x]
   291[incomplete b run]
   292[incomplete b run a]
   293[incomplete c]
   294[incomplete c A]
   295[incomplete c x]
   296[incomplete c run]
   297[incomplete c run a]
   298[incomplete c A]
   299[incomplete c x2]
   300[incomplete c run2]
   301[incomplete c run2 a]
   302[incomplete d]
   303[incomplete d A]
   304[incomplete d x]
   305[incomplete d run]
   306[incomplete d run a]
   307[incomplete d A]
   308[incomplete d x2]
   309[incomplete d run2]
   310[incomplete d run2 a]
   311[unresolvedDisjunction]
   312[unresolvedDisjunction #TypePrimitive]
   313[unresolvedDisjunction #TypePrimitive _args]
   314[unresolvedDisjunction #TypePrimitive _args required]
   315[unresolvedDisjunction #TypePrimitive Args]
   316[unresolvedDisjunction #TypePrimitive Args required]
   317[unresolvedDisjunction #TypePrimitive "*"]
   318[unresolvedDisjunction #TypeBool]
   319[unresolvedDisjunction #TypeBool _args]
   320[unresolvedDisjunction #TypeBool _args required]
   321[unresolvedDisjunction #TypeBool Args]
   322[unresolvedDisjunction #TypeBool Args required]
   323[cfgs]
   324[cfgs 0]
   325[cfgs 0 metadata]
   326[cfgs 0 metadata name]
   327[cfgs 1]
   328[cfgs 1 metadata]
   329[cfgs 1 metadata name]
   330[filepath]
   331[files]
   332[scoped]
   333[scoped _args]
   334[scoped _args required]
   335[scoped direct]
   336[scoped direct Args]
   337[scoped direct Args required]
   338[scoped direct a]
   339[scoped embed1]
   340[scoped embed1 Args]
   341[scoped embed1 Args required]
   342[scoped embed1 a]
   343[scoped embed2]
   344[scoped embed2 Args]
   345[scoped embed2 Args required]
   346[scoped embed2 a]
   347[scoped list]
   348[scoped list Args]
   349[scoped list Args required]
   350[scoped list a]
   351[scoped list a 0]
   352[scoped listStruct]
   353[scoped listStruct Args]
   354[scoped listStruct Args required]
   355[scoped listStruct a]
   356[scoped listStruct a 0]
   357[scoped listStruct a 0 a]
   358[scoped listEmbed]
   359[scoped listEmbed Args]
   360[scoped listEmbed Args required]
   361[scoped listEmbed a]
   362[scoped listEmbed a 0]
   363[x]
   364[Y]
   365[y]
   366[Y]
   367-- out/value --
   368== Simplified
   369{
   370	comprehension: {
   371		for cfg in [{
   372			a: "one"
   373		}] {
   374			let filepath = "kind-\(cfg.name)"
   375			"\(filepath)": {
   376				patches: cfg
   377			}
   378		}
   379	}
   380	complete: {
   381		x: "a foo z"
   382		run: {
   383			a: "foo"
   384		}
   385	}
   386	cfgs: [{
   387		metadata: {
   388			name: "one"
   389		}
   390	}, {
   391		metadata: {
   392			name: "two"
   393		}
   394	}]
   395	files: {
   396		"\("kind-\(cfg.name)")": {
   397			patches: cfg
   398		}
   399	}
   400	scoped: {
   401		direct: {
   402			a: 1
   403		}
   404		embed1: {
   405			a: 1
   406		}
   407		embed2: {
   408			a: 1
   409		}
   410		list: {
   411			a: [1]
   412		}
   413		listStruct: {
   414			a: [{
   415				a: 1
   416			}]
   417		}
   418		listEmbed: {
   419			a: [1]
   420		}
   421	}
   422	x: "foo"
   423	incomplete: {
   424		a: {
   425			x: "a \(run.a) z"
   426			run: {
   427				a: string
   428			}
   429		}
   430		b: {
   431			let A = run.a
   432			x: "a \(A) z"
   433			run: {
   434				a: string
   435			}
   436		}
   437		c: {
   438			let A_1 = run.a
   439			let A_2 = run2.a
   440			x:  "a \(A_1) z"
   441			x2: "a \(A_2) z"
   442			run: {
   443				a: string
   444			}
   445			run2: {
   446				a: string
   447			}
   448		}
   449		d: {
   450			let A_3 = run.a
   451			let A_4 = run2.a
   452			x:  "a \(A_3) z"
   453			x2: "a \(A_4) z"
   454			run: {
   455				a: string
   456			}
   457			run2: {
   458				a: string
   459			}
   460		}
   461	}
   462	unresolvedDisjunction: {}
   463	y: "foo"
   464}
   465== Raw
   466{
   467	comprehension: {
   468		for cfg in [{
   469			a: "one"
   470		}] {
   471			let filepath = "kind-\(cfg.name)"
   472			"\(filepath)": {
   473				patches: cfg
   474			}
   475		}
   476	}
   477	#Foo: 2
   478	complete: {
   479		x: "a foo z"
   480		run: {
   481			a: "foo"
   482		}
   483	}
   484	cfgs: [{
   485		metadata: {
   486			name: "one"
   487		}
   488	}, {
   489		metadata: {
   490			name: "two"
   491		}
   492	}]
   493	files: {
   494		"\("kind-\(cfg.name)")": {
   495			patches: cfg
   496		}
   497	}
   498	scoped: {
   499		_args: {
   500			required: 1
   501		}
   502		direct: {
   503			a: 1
   504		}
   505		embed1: {
   506			a: 1
   507		}
   508		embed2: {
   509			a: 1
   510		}
   511		list: {
   512			a: [1]
   513		}
   514		listStruct: {
   515			a: [{
   516				a: 1
   517			}]
   518		}
   519		listEmbed: {
   520			a: [1]
   521		}
   522	}
   523	x: "foo"
   524	incomplete: {
   525		a: {
   526			x: "a \(run.a) z"
   527			run: {
   528				a: string
   529			}
   530		}
   531		b: {
   532			let A = run.a
   533			x: "a \(A) z"
   534			run: {
   535				a: string
   536			}
   537		}
   538		c: {
   539			let A_1 = run.a
   540			let A_2 = run2.a
   541			x:  "a \(A_1) z"
   542			x2: "a \(A_2) z"
   543			run: {
   544				a: string
   545			}
   546			run2: {
   547				a: string
   548			}
   549		}
   550		d: {
   551			let A_3 = run.a
   552			let A_4 = run2.a
   553			x:  "a \(A_3) z"
   554			x2: "a \(A_4) z"
   555			run: {
   556				a: string
   557			}
   558			run2: {
   559				a: string
   560			}
   561		}
   562	}
   563	unresolvedDisjunction: {
   564		#TypePrimitive: {
   565			_args: {
   566				required: bool
   567			}
   568			"*": {}
   569		}
   570		#TypeBool: {
   571			let Args = _args
   572			_args: {
   573				required: bool
   574			}
   575
   576			if !Args.required {
   577				// `default` sets the default value.
   578				default: bool | null
   579			}
   580		}
   581	}
   582	y: "foo"
   583}
   584== Final
   585{
   586	comprehension: _|_ // invalid interpolation: cycle error
   587	complete: {
   588		x: "a foo z"
   589		run: {
   590			a: "foo"
   591		}
   592	}
   593	cfgs: [{
   594		metadata: {
   595			name: "one"
   596		}
   597	}, {
   598		metadata: {
   599			name: "two"
   600		}
   601	}]
   602	files: _|_ // invalid interpolation: cycle error (and 3 more errors)
   603	scoped: {
   604		direct: {
   605			a: 1
   606		}
   607		embed1: {
   608			a: 1
   609		}
   610		embed2: {
   611			a: 1
   612		}
   613		list: {
   614			a: [1]
   615		}
   616		listStruct: {
   617			a: [{
   618				a: 1
   619			}]
   620		}
   621		listEmbed: {
   622			a: [1]
   623		}
   624	}
   625	x: "foo"
   626	incomplete: {
   627		a: {
   628			x: _|_ // invalid interpolation: incomplete.a.x: non-concrete value string (type string)
   629			run: {
   630				a: string
   631			}
   632		}
   633		b: {
   634			x: _|_ // invalid interpolation: incomplete.b.x: non-concrete value string (type string)
   635			run: {
   636				a: string
   637			}
   638		}
   639		c: {
   640			x:  _|_ // invalid interpolation: incomplete.c.x: non-concrete value string (type string)
   641			x2: _|_ // invalid interpolation: incomplete.c.x2: non-concrete value string (type string)
   642			run: {
   643				a: string
   644			}
   645			run2: {
   646				a: string
   647			}
   648		}
   649		d: {
   650			x:  _|_ // invalid interpolation: incomplete.d.x: non-concrete value string (type string)
   651			x2: _|_ // invalid interpolation: incomplete.d.x2: non-concrete value string (type string)
   652			run: {
   653				a: string
   654			}
   655			run2: {
   656				a: string
   657			}
   658		}
   659	}
   660	unresolvedDisjunction: {}
   661	y: "foo"
   662}
   663== All
   664{
   665	comprehension: {
   666		for cfg in [{
   667			a: "one"
   668		}] {
   669			let filepath = "kind-\(cfg.name)"
   670			"\(filepath)": {
   671				patches: cfg
   672			}
   673		}
   674	}
   675	#Foo: 2
   676	complete: {
   677		x: "a foo z"
   678		run: {
   679			a: "foo"
   680		}
   681	}
   682	cfgs: [{
   683		metadata: {
   684			name: "one"
   685		}
   686	}, {
   687		metadata: {
   688			name: "two"
   689		}
   690	}]
   691	files: {
   692		"\("kind-\(cfg.name)")": {
   693			patches: cfg
   694		}
   695	}
   696	scoped: {
   697		_args: {
   698			required: 1
   699		}
   700		direct: {
   701			a: 1
   702		}
   703		embed1: {
   704			a: 1
   705		}
   706		embed2: {
   707			a: 1
   708		}
   709		list: {
   710			a: [1]
   711		}
   712		listStruct: {
   713			a: [{
   714				a: 1
   715			}]
   716		}
   717		listEmbed: {
   718			a: [1]
   719		}
   720	}
   721	x: "foo"
   722	incomplete: {
   723		a: {
   724			x: "a \(run.a) z"
   725			run: {
   726				a: string
   727			}
   728		}
   729		b: {
   730			let A = run.a
   731			x: "a \(A) z"
   732			run: {
   733				a: string
   734			}
   735		}
   736		c: {
   737			let A_1 = run.a
   738			let A_2 = run2.a
   739			x:  "a \(A_1) z"
   740			x2: "a \(A_2) z"
   741			run: {
   742				a: string
   743			}
   744			run2: {
   745				a: string
   746			}
   747		}
   748		d: {
   749			let A_3 = run.a
   750			let A_4 = run2.a
   751			x:  "a \(A_3) z"
   752			x2: "a \(A_4) z"
   753			run: {
   754				a: string
   755			}
   756			run2: {
   757				a: string
   758			}
   759		}
   760	}
   761	unresolvedDisjunction: {
   762		#TypePrimitive: {
   763			_args: {
   764				required: bool
   765			}
   766			"*": {}
   767		}
   768		#TypeBool: {
   769			let Args = _args
   770			_args: {
   771				required: bool
   772			}
   773
   774			if !Args.required {
   775				// `default` sets the default value.
   776				default: bool | null
   777			}
   778		}
   779	}
   780	y: "foo"
   781}
   782== Eval
   783{
   784	comprehension: {
   785		for cfg in [{
   786			a: "one"
   787		}] {
   788			let filepath = "kind-\(cfg.name)"
   789			"\(filepath)": {
   790				patches: cfg
   791			}
   792		}
   793	}
   794	#Foo: 2
   795	complete: {
   796		x: "a foo z"
   797		run: {
   798			a: "foo"
   799		}
   800	}
   801	cfgs: [{
   802		metadata: {
   803			name: "one"
   804		}
   805	}, {
   806		metadata: {
   807			name: "two"
   808		}
   809	}]
   810	files: {
   811		"\("kind-\(cfg.name)")": {
   812			patches: cfg
   813		}
   814	}
   815	scoped: {
   816		direct: {
   817			a: 1
   818		}
   819		embed1: {
   820			a: 1
   821		}
   822		embed2: {
   823			a: 1
   824		}
   825		list: {
   826			a: [1]
   827		}
   828		listStruct: {
   829			a: [{
   830				a: 1
   831			}]
   832		}
   833		listEmbed: {
   834			a: [1]
   835		}
   836	}
   837	x: "foo"
   838	incomplete: {
   839		a: {
   840			x: "a \(run.a) z"
   841			run: {
   842				a: string
   843			}
   844		}
   845		b: {
   846			let A = run.a
   847			x: "a \(A) z"
   848			run: {
   849				a: string
   850			}
   851		}
   852		c: {
   853			let A_1 = run.a
   854			let A_2 = run2.a
   855			x:  "a \(A_1) z"
   856			x2: "a \(A_2) z"
   857			run: {
   858				a: string
   859			}
   860			run2: {
   861				a: string
   862			}
   863		}
   864		d: {
   865			let A_3 = run.a
   866			let A_4 = run2.a
   867			x:  "a \(A_3) z"
   868			x2: "a \(A_4) z"
   869			run: {
   870				a: string
   871			}
   872			run2: {
   873				a: string
   874			}
   875		}
   876	}
   877	unresolvedDisjunction: {
   878		#TypePrimitive: {
   879			"*": {}
   880		}
   881		#TypeBool: {
   882			let Args = _args
   883			_args: {
   884				required: bool
   885			}
   886
   887			if !Args.required {
   888				default: bool | null
   889			}
   890		}
   891	}
   892	y: "foo"
   893}

View as plain text