| -- in.cue -- |
| a: { b: 2, c: int } |
| |
| wrongConcreteType: { |
| if a.b { |
| 2 |
| } |
| } |
| |
| wrongType: { |
| if a.c { |
| 2 |
| } |
| } |
| |
| incomplete: { |
| if a.d { |
| 2 |
| } |
| } |
| |
| incomplete: { |
| list: [1, 2, 3] |
| for x in list if a.d { |
| x |
| } |
| } |
| |
| // Issue #809 |
| useDefault: { |
| a: { |
| x: *"foo" | string |
| if x != _|_ { |
| y: x |
| } |
| } |
| |
| issue809: { |
| #A: { |
| a: string |
| b: *a | string |
| } |
| |
| s: [Name=string]: #A & { a: Name } |
| s: bar: _ |
| |
| foo: [ |
| for _, a in s if a.b != _|_ {a}, |
| ] |
| } |
| } |
| |
| -- out/compile -- |
| --- in.cue |
| { |
| a: { |
| b: 2 |
| c: int |
| } |
| wrongConcreteType: { |
| if 〈1;a〉.b { |
| 2 |
| } |
| } |
| wrongType: { |
| if 〈1;a〉.c { |
| 2 |
| } |
| } |
| incomplete: { |
| if 〈1;a〉.d { |
| 2 |
| } |
| } |
| incomplete: { |
| list: [ |
| 1, |
| 2, |
| 3, |
| ] |
| for _, x in 〈0;list〉 if 〈2;a〉.d { |
| 〈1;x〉 |
| } |
| } |
| useDefault: { |
| a: { |
| x: (*"foo"|string) |
| if (〈0;x〉 != _|_(explicit error (_|_ literal) in source)) { |
| y: 〈1;x〉 |
| } |
| } |
| issue809: { |
| #A: { |
| a: string |
| b: (*〈0;a〉|string) |
| } |
| s: { |
| [string]: (〈1;#A〉 & { |
| a: 〈1;-〉 |
| }) |
| } |
| s: { |
| bar: _ |
| } |
| foo: [ |
| for _, a in 〈0;s〉 if (〈0;a〉.b != _|_(explicit error (_|_ literal) in source)) { |
| 〈1;a〉 |
| }, |
| ] |
| } |
| } |
| } |
| -- out/eval -- |
| Errors: |
| wrongConcreteType: cannot use 2 (type int) as type bool: |
| ./in.cue:4:2 |
| ./in.cue:1:9 |
| wrongType: cannot use int (type int) as type bool: |
| ./in.cue:10:2 |
| |
| Result: |
| (_|_){ |
| // [eval] |
| a: (struct){ |
| b: (int){ 2 } |
| c: (int){ int } |
| } |
| wrongConcreteType: (_|_){ |
| // [eval] wrongConcreteType: cannot use 2 (type int) as type bool: |
| // ./in.cue:4:2 |
| // ./in.cue:1:9 |
| } |
| wrongType: (_|_){ |
| // [eval] wrongType: cannot use int (type int) as type bool: |
| // ./in.cue:10:2 |
| } |
| incomplete: (_|_){ |
| // [incomplete] incomplete: undefined field: d: |
| // ./in.cue:16:7 |
| // incomplete: undefined field: d: |
| // ./in.cue:23:21 |
| list: (#list){ |
| 0: (int){ 1 } |
| 1: (int){ 2 } |
| 2: (int){ 3 } |
| } |
| } |
| useDefault: (struct){ |
| a: (struct){ |
| x: (string){ |(*(string){ "foo" }, (string){ string }) } |
| y: (string){ |(*(string){ "foo" }, (string){ string }) } |
| } |
| issue809: (struct){ |
| #A: (#struct){ |
| a: (string){ string } |
| b: (string){ string } |
| } |
| s: (struct){ |
| bar: (#struct){ |
| a: (string){ "bar" } |
| b: (string){ |(*(string){ "bar" }, (string){ string }) } |
| } |
| } |
| foo: (#list){ |
| 0: (#struct){ |
| a: (string){ "bar" } |
| b: (string){ |(*(string){ "bar" }, (string){ string }) } |
| } |
| } |
| } |
| } |
| } |