Skip to content

Commit aeb3bf3

Browse files
committed
internal/core/adt: do not copy frozen flags
Disjuncts may legitimately add fields that undo the frozen nature. This improves the error messages of one other test. This adds one misaligned counter, which we will ignore for now. Fixes #3411 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: Ia1ec6d1b9fefef6a5e0328465d75eb637d947e83 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1200587 Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Matthew Sackman <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent 8ebddc1 commit aeb3bf3

File tree

4 files changed

+54
-13
lines changed

4 files changed

+54
-13
lines changed

cue/testdata/cycle/disjunction.txtar

+2-6
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ issue3042.data.secret: conflicting values string and {infra:[{name:"bar1"}]} (mi
158158
./issue3042.cue:8:11
159159
issue3042.data.secret: field not allowed:
160160
./issue3042.cue:8:3
161-
issue3042.data.secret.infra: adding field name not allowed as field set was already referenced
162161
issue3042.data.secret.infra: conflicting values [{name:"bar1"}] and string (mismatched types list and string):
163162
./issue3042.cue:5:12
164163
./issue3042.cue:9:11
@@ -277,7 +276,6 @@ Result:
277276
// ./issue3042.cue:8:11
278277
// issue3042.data.secret: field not allowed:
279278
// ./issue3042.cue:8:3
280-
// issue3042.data.secret.infra: adding field name not allowed as field set was already referenced
281279
// issue3042.data.secret.infra: conflicting values [{name:"bar1"}] and string (mismatched types list and string):
282280
// ./issue3042.cue:5:12
283281
// ./issue3042.cue:9:11
@@ -324,7 +322,7 @@ Result:
324322
diff old new
325323
--- old
326324
+++ new
327-
@@ -1,9 +1,60 @@
325+
@@ -1,9 +1,59 @@
328326
Errors:
329327
cycle.a: structural cycle
330328
+issue3042.data: conflicting values [...#nesting] and {secret:{infra:[{name:"bar1"}]}} (mismatched types list and struct):
@@ -341,7 +339,6 @@ diff old new
341339
+ ./issue3042.cue:8:11
342340
+issue3042.data.secret: field not allowed:
343341
+ ./issue3042.cue:8:3
344-
+issue3042.data.secret.infra: adding field name not allowed as field set was already referenced
345342
+issue3042.data.secret.infra: conflicting values [{name:"bar1"}] and string (mismatched types list and string):
346343
+ ./issue3042.cue:5:12
347344
+ ./issue3042.cue:9:11
@@ -386,7 +383,7 @@ diff old new
386383
cycle: (_|_){
387384
// [structural cycle]
388385
a: (_|_){
389-
@@ -58,22 +109,70 @@
386+
@@ -58,22 +108,69 @@
390387
x: (#list){
391388
}
392389
}
@@ -424,7 +421,6 @@ diff old new
424421
+ // ./issue3042.cue:8:11
425422
+ // issue3042.data.secret: field not allowed:
426423
+ // ./issue3042.cue:8:3
427-
+ // issue3042.data.secret.infra: adding field name not allowed as field set was already referenced
428424
+ // issue3042.data.secret.infra: conflicting values [{name:"bar1"}] and string (mismatched types list and string):
429425
+ // ./issue3042.cue:5:12
430426
+ // ./issue3042.cue:9:11

cue/testdata/eval/disjunctions.txtar

+51-5
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,21 @@ issue3406: {
138138
d: kind: "foo" | "bar"
139139
d: { kind: "foo" } | { kind: "bar" }
140140
}
141+
-- issue3411.cue --
142+
issue3411: {
143+
x: y?: [...string]
144+
x: {y: ["foo"]} | *{y: ["bar"]}
145+
}
141146
-- out/eval/stats --
142147
Leaks: 0
143-
Freed: 347
144-
Reused: 335
148+
Freed: 355
149+
Reused: 343
145150
Allocs: 12
146151
Retain: 0
147152

148-
Unifications: 158
149-
Conjuncts: 633
150-
Disjuncts: 347
153+
Unifications: 164
154+
Conjuncts: 647
155+
Disjuncts: 355
151156
-- out/evalalpha --
152157
Errors:
153158
f.name: conflicting values "int" and "str":
@@ -319,6 +324,17 @@ Result:
319324
kind: (string){ "bar" }
320325
}) }
321326
}
327+
issue3411: (struct){
328+
x: (struct){ |(*(struct){
329+
y: (#list){
330+
0: (string){ "bar" }
331+
}
332+
}, (struct){
333+
y: (#list){
334+
0: (string){ "foo" }
335+
}
336+
}) }
337+
}
322338
}
323339
-- diff/-out/evalalpha<==>+out/eval --
324340
diff old new
@@ -560,6 +576,17 @@ Result:
560576
kind: (string){ "bar" }
561577
}) }
562578
}
579+
issue3411: (struct){
580+
x: (struct){ |(*(struct){
581+
y: (#list){
582+
0: (string){ "bar" }
583+
}
584+
}, (struct){
585+
y: (#list){
586+
0: (string){ "foo" }
587+
}
588+
}) }
589+
}
563590
}
564591
-- out/compile --
565592
--- in.cue
@@ -762,3 +789,22 @@ Result:
762789
})
763790
}
764791
}
792+
--- issue3411.cue
793+
{
794+
issue3411: {
795+
x: {
796+
y?: [
797+
...string,
798+
]
799+
}
800+
x: ({
801+
y: [
802+
"foo",
803+
]
804+
}|*{
805+
y: [
806+
"bar",
807+
]
808+
})
809+
}
810+
}

internal/core/adt/eval_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ var skipDebugDepErrors = map[string]int{
8989
"disjunctions/embed": 6,
9090
"disjunctions/errors": 2,
9191
"eval/conjuncts": 3,
92+
"eval/disjunctions": 1,
9293
"eval/issue2146": 4,
9394
"eval/issue599": 1,
9495
"export/031": 1,

internal/core/adt/overlay.go

-2
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,6 @@ func (ctx *overlayContext) cloneScheduler(dst, src *nodeContext) {
434434
ds.completed = ss.completed
435435
ds.needs = ss.needs
436436
ds.provided = ss.provided
437-
ds.frozen = ss.frozen
438-
ds.isFrozen = ss.isFrozen
439437
ds.counters = ss.counters
440438

441439
ss.blocking = ss.blocking[:0]

0 commit comments

Comments
 (0)