-- 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" -- variant1.cue -- #V1: { x: close({ f1: int }) x: f2: 2 } -- out/eval/stats -- Leaks: 3 Freed: 16 Reused: 12 Allocs: 7 Retain: 4 Unifications: 19 Conjuncts: 33 Disjuncts: 20 -- out/evalalpha -- Errors: z.x.f2: field not allowed: ./in.cue:5:6 ./in.cue:14:3 #V1.x.f2: field not allowed: ./variant1.cue:2:5 ./variant1.cue:3:5 Result: (_|_){ // [eval] #T: (#struct){ x: (#struct){ f1: (int){ int } } } z: (_|_){ // [eval] x: (_|_){ // [eval] f1: (int){ 99 } f2: (_|_){ // [eval] z.x.f2: field not allowed: // ./in.cue:5:6 // ./in.cue:14:3 } } } t: (#struct){ p: (string){ "foo" } } #C: (#struct){ p: (_){ _ } } #V1: (_|_){ // [eval] x: (_|_){ // [eval] f2: (_|_){ // [eval] #V1.x.f2: field not allowed: // ./variant1.cue:2:5 // ./variant1.cue:3:5 } f1: (int){ int } } } } -- diff/-out/evalalpha<==>+out/eval -- diff old new --- old +++ new @@ -1,12 +1,10 @@ Errors: -#V1.x.f2: field not allowed: - ./variant1.cue:2:11 - ./variant1.cue:3:5 z.x.f2: field not allowed: - ./in.cue:2:2 - ./in.cue:5:12 - ./in.cue:11:4 + ./in.cue:5:6 ./in.cue:14:3 +#V1.x.f2: field not allowed: + ./variant1.cue:2:5 + ./variant1.cue:3:5 Result: (_|_){ @@ -23,9 +21,7 @@ f1: (int){ 99 } f2: (_|_){ // [eval] z.x.f2: field not allowed: - // ./in.cue:2:2 - // ./in.cue:5:12 - // ./in.cue:11:4 + // ./in.cue:5:6 // ./in.cue:14:3 } } @@ -40,12 +36,12 @@ // [eval] x: (_|_){ // [eval] - f1: (int){ int } f2: (_|_){ // [eval] #V1.x.f2: field not allowed: - // ./variant1.cue:2:11 + // ./variant1.cue:2:5 // ./variant1.cue:3:5 } + f1: (int){ int } } } } -- diff/todo/p2 -- Missing positions -- diff/todo/p3 -- Reordering -- out/eval -- Errors: #V1.x.f2: field not allowed: ./variant1.cue:2:11 ./variant1.cue:3:5 z.x.f2: field not allowed: ./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.f2: field not allowed: // ./in.cue:2:2 // ./in.cue:5:12 // ./in.cue:11:4 // ./in.cue:14:3 } } } t: (#struct){ p: (string){ "foo" } } #C: (#struct){ p: (_){ _ } } #V1: (_|_){ // [eval] x: (_|_){ // [eval] f1: (int){ int } f2: (_|_){ // [eval] #V1.x.f2: field not allowed: // ./variant1.cue:2:11 // ./variant1.cue:3:5 } } } } -- 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" } } --- variant1.cue { #V1: { x: close({ f1: int }) x: { f2: 2 } } }