You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
internal/encoding/gotypes: generate disjunctions of structs as a map
For a simple and closed CUE struct, we can generate a Go struct.
However, for a disjunction of structs we cannot generate a single
Go struct in the general case. For now, generate a map[string]any,
which is fairly loose but at least will work.
Ideas for future enhancements are left under a TODO.
Note that we were incorrectly generating pointers to maps,
given that the decision to use a Go pointer was made before
the decision to use a Go map to represent a CUE struct.
This is resolved now as well, along with regression tests.
Signed-off-by: Daniel Martí <[email protected]>
Change-Id: I2ce4eb40b107b456c20a44d28332df668be33045
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1207219
Reviewed-by: Roger Peppe <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
fail.cue."11_Int8".types.Int8: invalid value 99999 (out of bound <=127):
222
-
./cuetest/all.cue:62:30
221
+
./cuetest/all.cue:61:30
223
222
fail.cue."12_Int8".types.Int8: invalid value -99999 (out of bound >=-128):
224
-
./cuetest/all.cue:63:30
223
+
./cuetest/all.cue:62:30
225
224
fail.cue."18_IntListClosed2".types.IntListClosed2: incompatible list lengths (2 and 4)
226
225
fail.cue."29_NullOrStruct".types.NullOrStruct: 2 errors in empty disjunction:
227
226
fail.cue."29_NullOrStruct".types.NullOrStruct: conflicting values "foo" and null (mismatched types string and null):
228
-
./cuetest/all.cue:82:43
227
+
./cuetest/all.cue:81:43
229
228
./cuetest/fail_check.cue:7:12
230
229
./cuetest/fail_check.cue:7:17
231
230
./root/root.cue:12:10
232
231
./root/types.cue:35:23
233
232
fail.cue."29_NullOrStruct".types.NullOrStruct: conflicting values "foo" and {foo?:int} (mismatched types string and struct):
234
-
./cuetest/all.cue:82:43
233
+
./cuetest/all.cue:81:43
235
234
./cuetest/fail_check.cue:7:12
236
235
./cuetest/fail_check.cue:7:17
237
236
./root/root.cue:12:10
238
237
./root/types.cue:35:30
239
238
fail.cue."32_NullOrString".types.NullOrString: 2 errors in empty disjunction:
240
239
fail.cue."32_NullOrString".types.NullOrString: conflicting values 123 and null (mismatched types int and null):
241
-
./cuetest/all.cue:85:43
240
+
./cuetest/all.cue:84:43
242
241
./cuetest/fail_check.cue:7:12
243
242
./cuetest/fail_check.cue:7:17
244
243
./root/root.cue:12:10
245
244
./root/types.cue:36:23
246
245
fail.cue."32_NullOrString".types.NullOrString: conflicting values 123 and string (mismatched types int and string):
247
-
./cuetest/all.cue:85:43
246
+
./cuetest/all.cue:84:43
248
247
./cuetest/fail_check.cue:7:12
249
248
./cuetest/fail_check.cue:7:17
250
249
./root/root.cue:12:10
251
250
./root/types.cue:36:30
252
251
fail.cue."39_UniqueStrings".types.UniqueStrings: invalid value ["foo","foo"] (does not satisfy list.UniqueItems): equal value ("foo") at position 0 and 1:
253
-
./cuetest/all.cue:26:55
252
+
./cuetest/all.cue:25:55
254
253
./root/types.cue:39:23
255
254
fail.cue."9_Uint".types.Uint: invalid value -34 (out of bound >=0):
256
-
./cuetest/all.cue:60:30
255
+
./cuetest/all.cue:59:30
257
256
fail.cue.discBoth.discriminatorField: 2 errors in empty disjunction:
258
257
fail.cue.discBoth.discriminatorField.one: field not allowed:
259
258
./cuetest/all.cue:14:43
@@ -273,11 +272,11 @@ fail.cue.isNotEqual.mustEqual2: conflicting values 8 and 99:
273
272
./root/root.cue:77:15
274
273
fail.cue."34_NumericBounds".types.NumericBounds: invalid value 5555 (out of bound <100):
275
274
./root/types.cue:37:28
276
-
./cuetest/all.cue:87:43
275
+
./cuetest/all.cue:86:43
277
276
fail.cue."36_NonEmptyString".types.NonEmptyString: invalid value "" (out of bound !=""):
278
277
./root/types.cue:38:32
279
-
./cuetest/all.cue:26:55
280
-
./cuetest/all.cue:89:43
278
+
./cuetest/all.cue:25:55
279
+
./cuetest/all.cue:88:43
281
280
./root/types.cue:38:23
282
281
-- go.mod --
283
282
module "foo.test/bar"
@@ -315,8 +314,11 @@ func main() {
315
314
// It's easier to test the fields with a root value.
316
315
// We use reflection to ensure that inline struct pointers are initialized.
0 commit comments