cuelang.org/go@v0.13.0/internal/core/export/testdata/main/alias.txtar (about)

     1  // TODO: merge the resulting files. This can only be done if off-by-one handling
     2  // is moved to expr handling too.
     3  //
     4  // For now this is better than panicking.
     5  
     6  -- x.cue --
     7  fieldAlias: simple: {
     8  	X="a-b": 4
     9  	foo:     X
    10  
    11  	bar?: Y
    12  
    13  	Y="a-c": 5
    14  }
    15  
    16  valueAlias: merge: {
    17  	// Merge fields, rename alias to avoid conflict.
    18  	// TODO: merged values can still be simplified.
    19  	value: X={#value: X.b, b: 2}
    20  	value: Y={#value: Y.b, b: 2, v: X: 3}
    21  }
    22  
    23  valueAlias: selfRef: struct: {
    24  	a: b: X={#foo: X.b, b: 2}
    25  }
    26  
    27  valueAlias: selfRefValue: struct: {
    28  	// Note: this resolves to a cycle error, which is considered
    29  	// to be equal to "incomplete". As a result, in case of
    30  	// non-final evaluation, reference will remain. This is not
    31  	// an issue exclusive to value aliases, and falls within the
    32  	// range of what is acceptable for now.
    33  	// TODO: solve this issue.
    34  	a: X=or(X)
    35  }
    36  
    37  valueAlias: selfRefValue: pattern: {
    38  	// this triggers the verbatim "adt" path. Note that there
    39  	// is no need to rename the variable here as the expression
    40  	// was known to compile and is known to be correct.
    41  	a: [string]: X=or(X)
    42  }
    43  
    44  issue1308: {
    45  	let _xA = 1
    46  	sub: [{_A: _xA}]
    47  }
    48  
    49  // TODO: these could be merged into a single struct.
    50  issue2374: {
    51  	r=[string]: {z: 1, b: r | null}
    52  	a: {r: 0}
    53  }
    54  -- y.cue --
    55  fieldAlias: cross: {
    56  	baz: 3
    57  	X="d-2": E=[D="cue"]: C="foo\(baz)": {
    58  		name: "xx"
    59  		foo:  C.name
    60  		bar:  X
    61  		baz:  D
    62  		qux:  E
    63  	}
    64  }
    65  -- out/definition --
    66  fieldAlias: {
    67  	simple: {
    68  		X="a-b": 4
    69  		foo:     X
    70  		bar?:    Y
    71  		Y="a-c": 5
    72  	}
    73  	cross: {
    74  		baz: 3
    75  		X="d-2": {
    76  			E=[D="cue"]: {
    77  				C="foo3": {
    78  					name: "xx"
    79  					foo:  C.name
    80  					bar:  X
    81  					baz:  D
    82  					qux:  E
    83  				}
    84  			}
    85  		}
    86  	}
    87  }
    88  valueAlias: {
    89  	merge: {
    90  		// Merge fields, rename alias to avoid conflict.
    91  		// TODO: merged values can still be simplified.
    92  		value: X_1={
    93  			#value: X_1.b & X_1.b
    94  			b:      2
    95  			v: {
    96  				X: 3
    97  			}
    98  		}
    99  	}
   100  	selfRef: {
   101  		struct: {
   102  			a: {
   103  				b: X_2={
   104  					#foo: X_2.b
   105  					b:    2
   106  				}
   107  			}
   108  		}
   109  	}
   110  	selfRefValue: {
   111  		struct: {
   112  			// Note: this resolves to a cycle error, which is considered
   113  			// to be equal to "incomplete". As a result, in case of
   114  			// non-final evaluation, reference will remain. This is not
   115  			// an issue exclusive to value aliases, and falls within the
   116  			// range of what is acceptable for now.
   117  			// TODO: solve this issue.
   118  			a: X_3=or(X_3)
   119  		}
   120  		pattern: {
   121  			// this triggers the verbatim "adt" path. Note that there
   122  			// is no need to rename the variable here as the expression
   123  			// was known to compile and is known to be correct.
   124  			a: {
   125  				[string]: X=or(X)
   126  			}
   127  		}
   128  	}
   129  }
   130  issue1308: {
   131  	let _xA = 1
   132  	sub: [{
   133  		_A: _xA
   134  	}]
   135  }
   136  
   137  // TODO: these could be merged into a single struct.
   138  issue2374: {
   139  	r_1=[string]: {
   140  		z: 1
   141  		b: r_1 | null
   142  	}
   143  	a: {
   144  		r: 0
   145  	}
   146  }
   147  -- out/doc --
   148  []
   149  [fieldAlias]
   150  [fieldAlias simple]
   151  [fieldAlias simple "a-b"]
   152  [fieldAlias simple foo]
   153  [fieldAlias simple bar]
   154  [fieldAlias simple "a-c"]
   155  [fieldAlias cross]
   156  [fieldAlias cross baz]
   157  [fieldAlias cross "d-2"]
   158  [valueAlias]
   159  [valueAlias merge]
   160  [valueAlias merge value]
   161  - Merge fields, rename alias to avoid conflict.
   162  TODO: merged values can still be simplified.
   163  
   164  [valueAlias merge value #value]
   165  [valueAlias merge value b]
   166  [valueAlias merge value v]
   167  [valueAlias merge value v X]
   168  [valueAlias selfRef]
   169  [valueAlias selfRef struct]
   170  [valueAlias selfRef struct a]
   171  [valueAlias selfRef struct a b]
   172  [valueAlias selfRef struct a b #foo]
   173  [valueAlias selfRef struct a b b]
   174  [valueAlias selfRefValue]
   175  [valueAlias selfRefValue struct]
   176  [valueAlias selfRefValue struct a]
   177  - Note: this resolves to a cycle error, which is considered
   178  to be equal to "incomplete". As a result, in case of
   179  non-final evaluation, reference will remain. This is not
   180  an issue exclusive to value aliases, and falls within the
   181  range of what is acceptable for now.
   182  TODO: solve this issue.
   183  
   184  [valueAlias selfRefValue pattern]
   185  [valueAlias selfRefValue pattern a]
   186  - this triggers the verbatim "adt" path. Note that there
   187  is no need to rename the variable here as the expression
   188  was known to compile and is known to be correct.
   189  
   190  [issue1308]
   191  [issue1308 _xA]
   192  [issue1308 sub]
   193  [issue1308 sub 0]
   194  [issue1308 sub 0 _A]
   195  [issue2374]
   196  - TODO: these could be merged into a single struct.
   197  
   198  [issue2374 a]
   199  [issue2374 a r]
   200  [issue2374 a z]
   201  [issue2374 a b]
   202  -- out/value-v3 --
   203  == Simplified
   204  {
   205  	fieldAlias: {
   206  		cross: {
   207  			baz: 3
   208  			"d-2": {}
   209  		}
   210  		simple: {
   211  			"a-b": 4
   212  			foo:   4
   213  			"a-c": 5
   214  		}
   215  	}
   216  	valueAlias: {
   217  		merge: {
   218  			// Merge fields, rename alias to avoid conflict.
   219  			// TODO: merged values can still be simplified.
   220  			value: {
   221  				b: 2
   222  				v: {
   223  					X: 3
   224  				}
   225  			}
   226  		}
   227  		selfRef: {
   228  			struct: {
   229  				a: {
   230  					b: {
   231  						b: 2
   232  					}
   233  				}
   234  			}
   235  		}
   236  		selfRefValue: {
   237  			struct: {
   238  				// Note: this resolves to a cycle error, which is considered
   239  				// to be equal to "incomplete". As a result, in case of
   240  				// non-final evaluation, reference will remain. This is not
   241  				// an issue exclusive to value aliases, and falls within the
   242  				// range of what is acceptable for now.
   243  				// TODO: solve this issue.
   244  				a: or(X)
   245  			}
   246  			pattern: {
   247  				// this triggers the verbatim "adt" path. Note that there
   248  				// is no need to rename the variable here as the expression
   249  				// was known to compile and is known to be correct.
   250  				a: {}
   251  			}
   252  		}
   253  	}
   254  	issue1308: {
   255  		sub: [{}]
   256  	}
   257  
   258  	// TODO: these could be merged into a single struct.
   259  	issue2374: {
   260  		a: {
   261  			z: 1
   262  			b: null
   263  			r: 0
   264  		}
   265  	}
   266  }
   267  == Raw
   268  {
   269  	fieldAlias: {
   270  		cross: {
   271  			baz: 3
   272  			"d-2": {}
   273  		}
   274  		simple: {
   275  			"a-b": 4
   276  			foo:   4
   277  			bar?:  5
   278  			"a-c": 5
   279  		}
   280  	}
   281  	valueAlias: {
   282  		merge: {
   283  			// Merge fields, rename alias to avoid conflict.
   284  			// TODO: merged values can still be simplified.
   285  			value: {
   286  				#value: 2
   287  				b:      2
   288  				v: {
   289  					X: 3
   290  				}
   291  			}
   292  		}
   293  		selfRef: {
   294  			struct: {
   295  				a: {
   296  					b: {
   297  						#foo: 2
   298  						b:    2
   299  					}
   300  				}
   301  			}
   302  		}
   303  		selfRefValue: {
   304  			struct: {
   305  				// Note: this resolves to a cycle error, which is considered
   306  				// to be equal to "incomplete". As a result, in case of
   307  				// non-final evaluation, reference will remain. This is not
   308  				// an issue exclusive to value aliases, and falls within the
   309  				// range of what is acceptable for now.
   310  				// TODO: solve this issue.
   311  				a: or(X)
   312  			}
   313  			pattern: {
   314  				// this triggers the verbatim "adt" path. Note that there
   315  				// is no need to rename the variable here as the expression
   316  				// was known to compile and is known to be correct.
   317  				a: {}
   318  			}
   319  		}
   320  	}
   321  	issue1308: {
   322  		sub: [{
   323  			_A: 1
   324  		}]
   325  	}
   326  
   327  	// TODO: these could be merged into a single struct.
   328  	issue2374: {
   329  		a: {
   330  			z: 1
   331  			b: null
   332  			r: 0
   333  		}
   334  	}
   335  }
   336  == Final
   337  {
   338  	fieldAlias: {
   339  		cross: {
   340  			baz: 3
   341  			"d-2": {}
   342  		}
   343  		simple: {
   344  			"a-b": 4
   345  			foo:   4
   346  			"a-c": 5
   347  		}
   348  	}
   349  	valueAlias: {
   350  		merge: {
   351  			value: {
   352  				b: 2
   353  				v: {
   354  					X: 3
   355  				}
   356  			}
   357  		}
   358  		selfRef: {
   359  			struct: {
   360  				a: {
   361  					b: {
   362  						b: 2
   363  					}
   364  				}
   365  			}
   366  		}
   367  		selfRefValue: {
   368  			struct: {
   369  				a: _|_ // valueAlias.selfRefValue.struct.a: incomplete list: _ (and 1 more errors)
   370  			}
   371  			pattern: {
   372  				a: {}
   373  			}
   374  		}
   375  	}
   376  	issue1308: {
   377  		sub: [{}]
   378  	}
   379  	issue2374: {
   380  		a: {
   381  			z: 1
   382  			b: null
   383  			r: 0
   384  		}
   385  	}
   386  }
   387  == All
   388  {
   389  	fieldAlias: {
   390  		cross: {
   391  			baz: 3
   392  			"d-2": {}
   393  		}
   394  		simple: {
   395  			"a-b": 4
   396  			foo:   4
   397  			bar?:  5
   398  			"a-c": 5
   399  		}
   400  	}
   401  	valueAlias: {
   402  		merge: {
   403  			// Merge fields, rename alias to avoid conflict.
   404  			// TODO: merged values can still be simplified.
   405  			value: {
   406  				#value: 2
   407  				b:      2
   408  				v: {
   409  					X: 3
   410  				}
   411  			}
   412  		}
   413  		selfRef: {
   414  			struct: {
   415  				a: {
   416  					b: {
   417  						#foo: 2
   418  						b:    2
   419  					}
   420  				}
   421  			}
   422  		}
   423  		selfRefValue: {
   424  			struct: {
   425  				// Note: this resolves to a cycle error, which is considered
   426  				// to be equal to "incomplete". As a result, in case of
   427  				// non-final evaluation, reference will remain. This is not
   428  				// an issue exclusive to value aliases, and falls within the
   429  				// range of what is acceptable for now.
   430  				// TODO: solve this issue.
   431  				a: or(X)
   432  			}
   433  			pattern: {
   434  				// this triggers the verbatim "adt" path. Note that there
   435  				// is no need to rename the variable here as the expression
   436  				// was known to compile and is known to be correct.
   437  				a: {}
   438  			}
   439  		}
   440  	}
   441  	issue1308: {
   442  		sub: [{
   443  			_A: 1
   444  		}]
   445  	}
   446  
   447  	// TODO: these could be merged into a single struct.
   448  	issue2374: {
   449  		a: {
   450  			z: 1
   451  			b: null
   452  			r: 0
   453  		}
   454  	}
   455  }
   456  == Eval
   457  {
   458  	fieldAlias: {
   459  		cross: {
   460  			baz: 3
   461  			"d-2": {}
   462  		}
   463  		simple: {
   464  			"a-b": 4
   465  			foo:   4
   466  			bar?:  5
   467  			"a-c": 5
   468  		}
   469  	}
   470  	valueAlias: {
   471  		merge: {
   472  			value: {
   473  				#value: 2
   474  				b:      2
   475  				v: {
   476  					X: 3
   477  				}
   478  			}
   479  		}
   480  		selfRef: {
   481  			struct: {
   482  				a: {
   483  					b: {
   484  						#foo: 2
   485  						b:    2
   486  					}
   487  				}
   488  			}
   489  		}
   490  		selfRefValue: {
   491  			struct: {
   492  				a: or(X)
   493  			}
   494  			pattern: {
   495  				a: {}
   496  			}
   497  		}
   498  	}
   499  	issue1308: {
   500  		sub: [{}]
   501  	}
   502  	issue2374: {
   503  		a: {
   504  			z: 1
   505  			b: null
   506  			r: 0
   507  		}
   508  	}
   509  }
   510  -- diff/-out/value-v3<==>+out/value --
   511  diff old new
   512  --- old
   513  +++ new
   514  @@ -164,7 +164,7 @@
   515   		}
   516   		selfRefValue: {
   517   			struct: {
   518  -				a: _|_ // cycle error
   519  +				a: _|_ // valueAlias.selfRefValue.struct.a: incomplete list: _ (and 1 more errors)
   520   			}
   521   			pattern: {
   522   				a: {}
   523  -- diff/value/explanation --
   524  Improved error message.
   525  Reorderings?
   526  -- out/value --
   527  == Simplified
   528  {
   529  	fieldAlias: {
   530  		cross: {
   531  			baz: 3
   532  			"d-2": {}
   533  		}
   534  		simple: {
   535  			"a-b": 4
   536  			foo:   4
   537  			"a-c": 5
   538  		}
   539  	}
   540  	valueAlias: {
   541  		merge: {
   542  			// Merge fields, rename alias to avoid conflict.
   543  			// TODO: merged values can still be simplified.
   544  			value: {
   545  				b: 2
   546  				v: {
   547  					X: 3
   548  				}
   549  			}
   550  		}
   551  		selfRef: {
   552  			struct: {
   553  				a: {
   554  					b: {
   555  						b: 2
   556  					}
   557  				}
   558  			}
   559  		}
   560  		selfRefValue: {
   561  			struct: {
   562  				// Note: this resolves to a cycle error, which is considered
   563  				// to be equal to "incomplete". As a result, in case of
   564  				// non-final evaluation, reference will remain. This is not
   565  				// an issue exclusive to value aliases, and falls within the
   566  				// range of what is acceptable for now.
   567  				// TODO: solve this issue.
   568  				a: or(X)
   569  			}
   570  			pattern: {
   571  				// this triggers the verbatim "adt" path. Note that there
   572  				// is no need to rename the variable here as the expression
   573  				// was known to compile and is known to be correct.
   574  				a: {}
   575  			}
   576  		}
   577  	}
   578  	issue1308: {
   579  		sub: [{}]
   580  	}
   581  
   582  	// TODO: these could be merged into a single struct.
   583  	issue2374: {
   584  		a: {
   585  			z: 1
   586  			b: null
   587  			r: 0
   588  		}
   589  	}
   590  }
   591  == Raw
   592  {
   593  	fieldAlias: {
   594  		cross: {
   595  			baz: 3
   596  			"d-2": {}
   597  		}
   598  		simple: {
   599  			"a-b": 4
   600  			foo:   4
   601  			bar?:  5
   602  			"a-c": 5
   603  		}
   604  	}
   605  	valueAlias: {
   606  		merge: {
   607  			// Merge fields, rename alias to avoid conflict.
   608  			// TODO: merged values can still be simplified.
   609  			value: {
   610  				#value: 2
   611  				b:      2
   612  				v: {
   613  					X: 3
   614  				}
   615  			}
   616  		}
   617  		selfRef: {
   618  			struct: {
   619  				a: {
   620  					b: {
   621  						#foo: 2
   622  						b:    2
   623  					}
   624  				}
   625  			}
   626  		}
   627  		selfRefValue: {
   628  			struct: {
   629  				// Note: this resolves to a cycle error, which is considered
   630  				// to be equal to "incomplete". As a result, in case of
   631  				// non-final evaluation, reference will remain. This is not
   632  				// an issue exclusive to value aliases, and falls within the
   633  				// range of what is acceptable for now.
   634  				// TODO: solve this issue.
   635  				a: or(X)
   636  			}
   637  			pattern: {
   638  				// this triggers the verbatim "adt" path. Note that there
   639  				// is no need to rename the variable here as the expression
   640  				// was known to compile and is known to be correct.
   641  				a: {}
   642  			}
   643  		}
   644  	}
   645  	issue1308: {
   646  		sub: [{
   647  			_A: 1
   648  		}]
   649  	}
   650  
   651  	// TODO: these could be merged into a single struct.
   652  	issue2374: {
   653  		a: {
   654  			z: 1
   655  			b: null
   656  			r: 0
   657  		}
   658  	}
   659  }
   660  == Final
   661  {
   662  	fieldAlias: {
   663  		cross: {
   664  			baz: 3
   665  			"d-2": {}
   666  		}
   667  		simple: {
   668  			"a-b": 4
   669  			foo:   4
   670  			"a-c": 5
   671  		}
   672  	}
   673  	valueAlias: {
   674  		merge: {
   675  			value: {
   676  				b: 2
   677  				v: {
   678  					X: 3
   679  				}
   680  			}
   681  		}
   682  		selfRef: {
   683  			struct: {
   684  				a: {
   685  					b: {
   686  						b: 2
   687  					}
   688  				}
   689  			}
   690  		}
   691  		selfRefValue: {
   692  			struct: {
   693  				a: _|_ // cycle error
   694  			}
   695  			pattern: {
   696  				a: {}
   697  			}
   698  		}
   699  	}
   700  	issue1308: {
   701  		sub: [{}]
   702  	}
   703  	issue2374: {
   704  		a: {
   705  			z: 1
   706  			b: null
   707  			r: 0
   708  		}
   709  	}
   710  }
   711  == All
   712  {
   713  	fieldAlias: {
   714  		cross: {
   715  			baz: 3
   716  			"d-2": {}
   717  		}
   718  		simple: {
   719  			"a-b": 4
   720  			foo:   4
   721  			bar?:  5
   722  			"a-c": 5
   723  		}
   724  	}
   725  	valueAlias: {
   726  		merge: {
   727  			// Merge fields, rename alias to avoid conflict.
   728  			// TODO: merged values can still be simplified.
   729  			value: {
   730  				#value: 2
   731  				b:      2
   732  				v: {
   733  					X: 3
   734  				}
   735  			}
   736  		}
   737  		selfRef: {
   738  			struct: {
   739  				a: {
   740  					b: {
   741  						#foo: 2
   742  						b:    2
   743  					}
   744  				}
   745  			}
   746  		}
   747  		selfRefValue: {
   748  			struct: {
   749  				// Note: this resolves to a cycle error, which is considered
   750  				// to be equal to "incomplete". As a result, in case of
   751  				// non-final evaluation, reference will remain. This is not
   752  				// an issue exclusive to value aliases, and falls within the
   753  				// range of what is acceptable for now.
   754  				// TODO: solve this issue.
   755  				a: or(X)
   756  			}
   757  			pattern: {
   758  				// this triggers the verbatim "adt" path. Note that there
   759  				// is no need to rename the variable here as the expression
   760  				// was known to compile and is known to be correct.
   761  				a: {}
   762  			}
   763  		}
   764  	}
   765  	issue1308: {
   766  		sub: [{
   767  			_A: 1
   768  		}]
   769  	}
   770  
   771  	// TODO: these could be merged into a single struct.
   772  	issue2374: {
   773  		a: {
   774  			z: 1
   775  			b: null
   776  			r: 0
   777  		}
   778  	}
   779  }
   780  == Eval
   781  {
   782  	fieldAlias: {
   783  		cross: {
   784  			baz: 3
   785  			"d-2": {}
   786  		}
   787  		simple: {
   788  			"a-b": 4
   789  			foo:   4
   790  			bar?:  5
   791  			"a-c": 5
   792  		}
   793  	}
   794  	valueAlias: {
   795  		merge: {
   796  			value: {
   797  				#value: 2
   798  				b:      2
   799  				v: {
   800  					X: 3
   801  				}
   802  			}
   803  		}
   804  		selfRef: {
   805  			struct: {
   806  				a: {
   807  					b: {
   808  						#foo: 2
   809  						b:    2
   810  					}
   811  				}
   812  			}
   813  		}
   814  		selfRefValue: {
   815  			struct: {
   816  				a: or(X)
   817  			}
   818  			pattern: {
   819  				a: {}
   820  			}
   821  		}
   822  	}
   823  	issue1308: {
   824  		sub: [{}]
   825  	}
   826  	issue2374: {
   827  		a: {
   828  			z: 1
   829  			b: null
   830  			r: 0
   831  		}
   832  	}
   833  }