| |
| -- in.cue -- |
| #T: { |
| if true { |
| // We'd like to restrict the possible members of x in this case, |
| // but this doesn't work. |
| x: close({ |
| f1: int |
| }) |
| } |
| x: _ |
| } |
| z: #T & { |
| x: { |
| f1: 99 |
| f2: "i want to disallow this" |
| } |
| } |
| |
| t: #C |
| #C: { |
| if true { |
| p: _ |
| } |
| } |
| t: p: "foo" |
| -- out/eval -- |
| Errors: |
| z.x: field not allowed: f2: |
| ./in.cue:2:2 |
| ./in.cue:5:12 |
| ./in.cue:11:4 |
| ./in.cue:14:3 |
| |
| Result: |
| (_|_){ |
| // [eval] |
| #T: (#struct){ |
| x: (#struct){ |
| f1: (int){ int } |
| } |
| } |
| z: (_|_){ |
| // [eval] |
| x: (_|_){ |
| // [eval] |
| f1: (int){ 99 } |
| f2: (_|_){ |
| // [eval] z.x: field not allowed: f2: |
| // ./in.cue:2:2 |
| // ./in.cue:5:12 |
| // ./in.cue:11:4 |
| // ./in.cue:14:3 |
| } |
| } |
| } |
| t: (#struct){ |
| p: (string){ "foo" } |
| } |
| #C: (#struct){ |
| p: (_){ _ } |
| } |
| } |
| -- out/compile -- |
| --- in.cue |
| { |
| #T: { |
| if true { |
| x: close({ |
| f1: int |
| }) |
| } |
| x: _ |
| } |
| z: (〈0;#T〉 & { |
| x: { |
| f1: 99 |
| f2: "i want to disallow this" |
| } |
| }) |
| t: 〈0;#C〉 |
| #C: { |
| if true { |
| p: _ |
| } |
| } |
| t: { |
| p: "foo" |
| } |
| } |