...
1Interaction between defaults, embedding and disjunctions.
2
3// TODO: at the moment, using a default will select it.
4-- in.cue --
5x: {
6 // All of these resolve to *2 | 3
7 m1: (1 | (*2 | 3)) & (>=2 & <=3)
8 m2: (1 | (*2 | 3)) & (2 | 3)
9 m3: (*1 | *(*2 | 3)) & (2 | 3)
10}
11y1: x & {
12 {m4: x.m1 + x.m2 + x.m3}
13}
14y2: {
15 x
16 {m4: y2.m1 + y2.m2 + y2.m3}
17}
18Y=y3: {
19 x
20 {m4: Y.m1 + Y.m2 + Y.m3}
21}
22y4: x & {
23 {m4: y4.m1 + y4.m2 + y4.m3}
24}
25
26// Second disjunct in embedding is not possible because of previous declaration
27// of `b`, so it should be resolved to {a: 1}.
28b: (*"a" | "b") | "c"
29{a: b} | {b: int}
30-- out/eval/stats --
31Leaks: 0
32Freed: 306
33Reused: 296
34Allocs: 10
35Retain: 0
36
37Unifications: 52
38Conjuncts: 373
39Disjuncts: 306
40-- out/eval --
41(struct){
42 x: (struct){
43 m1: (int){ |(*(int){ 2 }, (int){ 3 }) }
44 m2: (int){ |(*(int){ 2 }, (int){ 3 }) }
45 m3: (int){ |(*(int){ 2 }, (int){ 3 }) }
46 }
47 y1: (struct){
48 m1: (int){ |(*(int){ 2 }, (int){ 3 }) }
49 m2: (int){ |(*(int){ 2 }, (int){ 3 }) }
50 m3: (int){ |(*(int){ 2 }, (int){ 3 }) }
51 m4: (int){ 6 }
52 }
53 y2: (struct){
54 m1: (int){ |(*(int){ 2 }, (int){ 3 }) }
55 m2: (int){ |(*(int){ 2 }, (int){ 3 }) }
56 m3: (int){ |(*(int){ 2 }, (int){ 3 }) }
57 m4: (int){ 6 }
58 }
59 y3: (struct){
60 m1: (int){ |(*(int){ 2 }, (int){ 3 }) }
61 m2: (int){ |(*(int){ 2 }, (int){ 3 }) }
62 m3: (int){ |(*(int){ 2 }, (int){ 3 }) }
63 m4: (int){ 6 }
64 }
65 y4: (struct){
66 m1: (int){ |(*(int){ 2 }, (int){ 3 }) }
67 m2: (int){ |(*(int){ 2 }, (int){ 3 }) }
68 m3: (int){ |(*(int){ 2 }, (int){ 3 }) }
69 m4: (int){ 6 }
70 }
71 b: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) }
72 a: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) }
73}
74-- out/compile --
75--- in.cue
76{
77 x: {
78 m1: ((1|(*2|3)) & (>=2 & <=3))
79 m2: ((1|(*2|3)) & (2|3))
80 m3: ((*1|*(*2|3)) & (2|3))
81 }
82 y1: (〈0;x〉 & {
83 {
84 m4: ((〈2;x〉.m1 + 〈2;x〉.m2) + 〈2;x〉.m3)
85 }
86 })
87 y2: {
88 〈1;x〉
89 {
90 m4: ((〈2;y2〉.m1 + 〈2;y2〉.m2) + 〈2;y2〉.m3)
91 }
92 }
93 y3: {
94 〈1;x〉
95 {
96 m4: ((〈2;y3〉.m1 + 〈2;y3〉.m2) + 〈2;y3〉.m3)
97 }
98 }
99 y4: (〈0;x〉 & {
100 {
101 m4: ((〈2;y4〉.m1 + 〈2;y4〉.m2) + 〈2;y4〉.m3)
102 }
103 })
104 b: ((*"a"|"b")|"c")
105 ({
106 a: 〈1;b〉
107 }|{
108 b: int
109 })
110}
View as plain text