github.com/joomcode/cue@v0.4.4-0.20221111115225-539fe3512047/cue/testdata/comprehensions/errors.txtar (about) 1 -- in.cue -- 2 circularIf: { 3 #list: { 4 tail: #list | *null 5 if tail != null { 6 } 7 } 8 } 9 10 circularFor: { 11 #list: { 12 tail: #list | *null 13 for x in tail != null { 14 } 15 } 16 } 17 18 // Print a bit more sensible error message than "empty disjunction" here. 19 // Issue #465 20 userError: { 21 a: string | *_|_ 22 if a != "" { 23 } 24 } 25 26 intField: { 27 for i, _ in [1, 2] { 28 (i): { 29 } 30 } 31 } 32 -- out/eval -- 33 Errors: 34 circularFor.#list: invalid operand tail != null (found bool, want list or struct): 35 ./in.cue:12:12 36 intField: integer fields not supported: 37 ./in.cue:27:4 38 39 Result: 40 (_|_){ 41 // [eval] 42 circularIf: (struct){ 43 #list: (#struct){ 44 tail: ((null|struct)){ |(*(null){ null }, (#struct){ 45 tail: (null){ null } 46 }) } 47 } 48 } 49 circularFor: (_|_){ 50 // [eval] 51 #list: (_|_){ 52 // [eval] circularFor.#list: invalid operand tail != null (found bool, want list or struct): 53 // ./in.cue:12:12 54 tail: (null){ null } 55 } 56 } 57 userError: (_|_){ 58 // [incomplete] userError: non-concrete value string in operand to !=: 59 // ./in.cue:21:5 60 // ./in.cue:20:5 61 a: (string){ string } 62 } 63 intField: (_|_){ 64 // [eval] intField: integer fields not supported: 65 // ./in.cue:27:4 66 0: (struct){ 67 } 68 1: (struct){ 69 } 70 } 71 } 72 -- out/compile -- 73 --- in.cue 74 { 75 circularIf: { 76 #list: { 77 tail: (〈1;#list〉|*null) 78 if (〈0;tail〉 != null) {} 79 } 80 } 81 circularFor: { 82 #list: { 83 tail: (〈1;#list〉|*null) 84 for _, x in (〈0;tail〉 != null) {} 85 } 86 } 87 userError: { 88 a: (string|*_|_(explicit error (_|_ literal) in source)) 89 if (〈0;a〉 != "") {} 90 } 91 intField: { 92 for i, _ in [ 93 1, 94 2, 95 ] { 96 〈1;i〉: {} 97 } 98 } 99 }