File: specdeviation.txtar

package info (click to toggle)
golang-github-cue-lang-cue 0.14.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,644 kB
  • sloc: makefile: 20; sh: 15
file content (232 lines) | stat: -rw-r--r-- 5,976 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
It turns out the semantics of the spec is somewhat awkward,
though theoretically nicer. It seems like we do need to change
the definition somewhat to make it less awkward, or at least
come up with a good workaround before adopting the spec.

We have introduce a small hack to mimic the old behavior for scalar
values.

Note that the value of p below is now 2 (default), but should
be the non-concrete 2 | int.

Proof:
    p: *((*1 | int) & 2)  | int   // substitution of both P conjuncts in p
    p: *(*_|_ | 2)  | int         // U1: distribute conjuncts
    p: *_|_ | 2  | int            // M2: remove mark
    p: 2  | int                   // value after removing default.

-- in.cue --
Q: *1 | int
q: *Q | int // 1 as expected

P: *1 | int
P: 2
p: *P | int // now 2, but should be (2 | int), according to the spec:

// Here the inner default may not be used as it is masked by the outer default.
r: (*3 | (*1 | 2)) & (1 | 2)

// Here the inner default is used, as there are no defaults marked in the
// outer disjunction.
s: (3 | (*1 | 2)) & (1 | 2)

s1: #Size & {min: 5}

#Size: {
	max: >min | *min
	res: uint | *0
	min: >res | *(1 + res)
}

staged: {
	c: ("a" | "b") & (*(*"a" | string) | string)
	d: (*(*"a" | string) | string) & ("a" | "b")
}

issue763a: {
	#A: {
		v: "a" | "b" | "c" // change to string to fix
	}

	h: [string]: #A

	h: [=~"^b"]: #A & {
		v: *h.a.v | string
	}

	h: a: {
		v: *"a" | string
	}

	h: baa: _
	h: boo: _
}
-- out/eval/stats --
Leaks:  0
Freed:  171
Reused: 158
Allocs: 13
Retain: 2

Unifications: 28
Conjuncts:    217
Disjuncts:    172
-- out/evalalpha --
(struct){
  Q: (int){ |(*(int){ 1 }, (int){ int }) }
  q: (int){ |(*(int){ 1 }, (int){ int }) }
  P: (int){ 2 }
  p: (int){ |(*(int){ 2 }, (int){ int }) }
  r: (int){ |((int){ 1 }, (int){ 2 }) }
  s: (int){ |(*(int){ 1 }, (int){ 2 }) }
  s1: (#struct){
    min: (int){ 5 }
    max: (number){ |(*(int){ 5 }, (number){ >5 }) }
    res: (int){ |(*(int){ 0 }, (int){ &(>=0, int) }) }
  }
  #Size: (#struct){
    max: (number){ |(*(int){ 1 }, (number){ >0 }, (number){ >1 }) }
    res: (int){ |(*(int){ 0 }, (int){ &(>=0, int) }) }
    min: (number){ |(*(int){ 1 }, (number){ >0 }) }
  }
  staged: (struct){
    c: (string){ |(*(string){ "a" }, *(string){ "b" }) }
    d: (string){ |(*(string){ "a" }, (string){ "b" }) }
  }
  issue763a: (struct){
    #A: (#struct){
      v: (string){ |((string){ "a" }, (string){ "b" }, (string){ "c" }) }
    }
    h: (struct){
      a: (#struct){
        v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) }
      }
      baa: (#struct){
        v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) }
      }
      boo: (#struct){
        v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) }
      }
    }
  }
}
-- diff/-out/evalalpha<==>+out/eval --
diff old new
--- old
+++ new
@@ -6,9 +6,9 @@
   r: (int){ |((int){ 1 }, (int){ 2 }) }
   s: (int){ |(*(int){ 1 }, (int){ 2 }) }
   s1: (#struct){
-    max: (number){ |(*(int){ 5 }, (number){ >5 }) }
-    res: (int){ |(*(int){ 0 }, (int){ &(>=0, int) }) }
     min: (int){ 5 }
+    max: (number){ |(*(int){ 5 }, (number){ >5 }) }
+    res: (int){ |(*(int){ 0 }, (int){ &(>=0, int) }) }
   }
   #Size: (#struct){
     max: (number){ |(*(int){ 1 }, (number){ >0 }, (number){ >1 }) }
@@ -16,7 +16,7 @@
     min: (number){ |(*(int){ 1 }, (number){ >0 }) }
   }
   staged: (struct){
-    c: (string){ |(*(string){ "a" }, (string){ "b" }) }
+    c: (string){ |(*(string){ "a" }, *(string){ "b" }) }
     d: (string){ |(*(string){ "a" }, (string){ "b" }) }
   }
   issue763a: (struct){
-- diff/explanation --
The changes in default behavior as are shown here are according to spec, as is
described at the top of the file. These changes may pose too much of a problem
for the transition to the new evaluator, though.
UPDATE: we have made evalv3 a bit more in line with evalv2. Note how this
affects staged.c, though.
TODO(defaults): consider these cases with a potential default redesign.
-- diff/todo/p3 --
Reordering.
-- out/eval --
(struct){
  Q: (int){ |(*(int){ 1 }, (int){ int }) }
  q: (int){ |(*(int){ 1 }, (int){ int }) }
  P: (int){ 2 }
  p: (int){ |(*(int){ 2 }, (int){ int }) }
  r: (int){ |((int){ 1 }, (int){ 2 }) }
  s: (int){ |(*(int){ 1 }, (int){ 2 }) }
  s1: (#struct){
    max: (number){ |(*(int){ 5 }, (number){ >5 }) }
    res: (int){ |(*(int){ 0 }, (int){ &(>=0, int) }) }
    min: (int){ 5 }
  }
  #Size: (#struct){
    max: (number){ |(*(int){ 1 }, (number){ >0 }, (number){ >1 }) }
    res: (int){ |(*(int){ 0 }, (int){ &(>=0, int) }) }
    min: (number){ |(*(int){ 1 }, (number){ >0 }) }
  }
  staged: (struct){
    c: (string){ |(*(string){ "a" }, (string){ "b" }) }
    d: (string){ |(*(string){ "a" }, (string){ "b" }) }
  }
  issue763a: (struct){
    #A: (#struct){
      v: (string){ |((string){ "a" }, (string){ "b" }, (string){ "c" }) }
    }
    h: (struct){
      a: (#struct){
        v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) }
      }
      baa: (#struct){
        v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) }
      }
      boo: (#struct){
        v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) }
      }
    }
  }
}
-- out/compile --
--- in.cue
{
  Q: (*1|int)
  q: (*〈0;Q〉|int)
  P: (*1|int)
  P: 2
  p: (*〈0;P〉|int)
  r: ((*3|(*1|2)) & (1|2))
  s: ((3|(*1|2)) & (1|2))
  s1: (〈0;#Size〉 & {
    min: 5
  })
  #Size: {
    max: (>〈0;min〉|*〈0;min〉)
    res: (&(int, >=0)|*0)
    min: (>〈0;res〉|*(1 + 〈0;res〉))
  }
  staged: {
    c: (("a"|"b") & (*(*"a"|string)|string))
    d: ((*(*"a"|string)|string) & ("a"|"b"))
  }
  issue763a: {
    #A: {
      v: ("a"|"b"|"c")
    }
    h: {
      [string]: 〈1;#A〉
    }
    h: {
      [=~"^b"]: (〈1;#A〉 & {
        v: (*〈2;h〉.a.v|string)
      })
    }
    h: {
      a: {
        v: (*"a"|string)
      }
    }
    h: {
      baa: _
    }
    h: {
      boo: _
    }
  }
}