github.com/joomcode/cue@v0.4.4-0.20221111115225-539fe3512047/internal/core/export/testdata/let.txtar (about)

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