| # DO NOT EDIT; generated by go run testdata/gen.go |
| # |
| #name: selecting |
| #evalPartial |
| -- in.cue -- |
| obj: {a: 1, b: 2} |
| index: {a: 1, b: 2}["b"] |
| mulidx: {a: 1, b: {a: 1, b: 3}}["b"]["b"] |
| e: {a: 1}[4] |
| f: {a: 1}.b |
| g: {a: 1}["b"] |
| h: [3].b |
| -- out/def -- |
| obj: { |
| a: 1 |
| b: 2 |
| } |
| index: 2 |
| mulidx: 3 |
| e: _|_ // invalid struct index 4 (type int) |
| f: { |
| a: 1 |
| }.b |
| g: { |
| a: 1 |
| }["b"] |
| h: _|_ // invalid operation: [3].b (type list does not support selection) |
| -- out/legacy-debug -- |
| <0>{obj: <1>{a: 1, b: 2}, index: 2, mulidx: 3, e: _|_(4:invalid struct index 4 (type int)), f: <2>{a: 1}.b, g: <3>{a: 1}["b"], h: _|_([3]:invalid operation: [3].b (type list does not support selection))} |
| -- out/compile -- |
| --- in.cue |
| { |
| obj: { |
| a: 1 |
| b: 2 |
| } |
| index: { |
| a: 1 |
| b: 2 |
| }["b"] |
| mulidx: { |
| a: 1 |
| b: { |
| a: 1 |
| b: 3 |
| } |
| }["b"]["b"] |
| e: { |
| a: 1 |
| }[4] |
| f: { |
| a: 1 |
| }.b |
| g: { |
| a: 1 |
| }["b"] |
| h: [ |
| 3, |
| ].b |
| } |
| -- out/eval -- |
| Errors: |
| e: invalid struct selector 4 (type int): |
| ./in.cue:4:16 |
| h: invalid list index b (type string): |
| ./in.cue:7:13 |
| |
| Result: |
| (_|_){ |
| // [eval] |
| obj: (struct){ |
| a: (int){ 1 } |
| b: (int){ 2 } |
| } |
| index: (int){ 2 } |
| mulidx: (int){ 3 } |
| e: (_|_){ |
| // [eval] e: invalid struct selector 4 (type int): |
| // ./in.cue:4:16 |
| } |
| f: (_|_){ |
| // [incomplete] f: undefined field b: |
| // ./in.cue:5:16 |
| } |
| g: (_|_){ |
| // [incomplete] g: undefined field b: |
| // ./in.cue:6:16 |
| } |
| h: (_|_){ |
| // [eval] h: invalid list index b (type string): |
| // ./in.cue:7:13 |
| } |
| } |