Skip to content

Commit

Permalink
internal/core/adt: do not copy frozen flags
Browse files Browse the repository at this point in the history
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 <mpvl@gmail.com>
Change-Id: Ia1ec6d1b9fefef6a5e0328465d75eb637d947e83
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1200587
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Matthew Sackman <matthew@cue.works>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
  • Loading branch information
mpvl committed Sep 5, 2024
1 parent 8ebddc1 commit aeb3bf3
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 13 deletions.
8 changes: 2 additions & 6 deletions cue/testdata/cycle/disjunction.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ issue3042.data.secret: conflicting values string and {infra:[{name:"bar1"}]} (mi
./issue3042.cue:8:11
issue3042.data.secret: field not allowed:
./issue3042.cue:8:3
issue3042.data.secret.infra: adding field name not allowed as field set was already referenced
issue3042.data.secret.infra: conflicting values [{name:"bar1"}] and string (mismatched types list and string):
./issue3042.cue:5:12
./issue3042.cue:9:11
Expand Down Expand Up @@ -277,7 +276,6 @@ Result:
// ./issue3042.cue:8:11
// issue3042.data.secret: field not allowed:
// ./issue3042.cue:8:3
// issue3042.data.secret.infra: adding field name not allowed as field set was already referenced
// issue3042.data.secret.infra: conflicting values [{name:"bar1"}] and string (mismatched types list and string):
// ./issue3042.cue:5:12
// ./issue3042.cue:9:11
Expand Down Expand Up @@ -324,7 +322,7 @@ Result:
diff old new
--- old
+++ new
@@ -1,9 +1,60 @@
@@ -1,9 +1,59 @@
Errors:
cycle.a: structural cycle
+issue3042.data: conflicting values [...#nesting] and {secret:{infra:[{name:"bar1"}]}} (mismatched types list and struct):
Expand All @@ -341,7 +339,6 @@ diff old new
+ ./issue3042.cue:8:11
+issue3042.data.secret: field not allowed:
+ ./issue3042.cue:8:3
+issue3042.data.secret.infra: adding field name not allowed as field set was already referenced
+issue3042.data.secret.infra: conflicting values [{name:"bar1"}] and string (mismatched types list and string):
+ ./issue3042.cue:5:12
+ ./issue3042.cue:9:11
Expand Down Expand Up @@ -386,7 +383,7 @@ diff old new
cycle: (_|_){
// [structural cycle]
a: (_|_){
@@ -58,22 +109,70 @@
@@ -58,22 +108,69 @@
x: (#list){
}
}
Expand Down Expand Up @@ -424,7 +421,6 @@ diff old new
+ // ./issue3042.cue:8:11
+ // issue3042.data.secret: field not allowed:
+ // ./issue3042.cue:8:3
+ // issue3042.data.secret.infra: adding field name not allowed as field set was already referenced
+ // issue3042.data.secret.infra: conflicting values [{name:"bar1"}] and string (mismatched types list and string):
+ // ./issue3042.cue:5:12
+ // ./issue3042.cue:9:11
Expand Down
56 changes: 51 additions & 5 deletions cue/testdata/eval/disjunctions.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,21 @@ issue3406: {
d: kind: "foo" | "bar"
d: { kind: "foo" } | { kind: "bar" }
}
-- issue3411.cue --
issue3411: {
x: y?: [...string]
x: {y: ["foo"]} | *{y: ["bar"]}
}
-- out/eval/stats --
Leaks: 0
Freed: 347
Reused: 335
Freed: 355
Reused: 343
Allocs: 12
Retain: 0

Unifications: 158
Conjuncts: 633
Disjuncts: 347
Unifications: 164
Conjuncts: 647
Disjuncts: 355
-- out/evalalpha --
Errors:
f.name: conflicting values "int" and "str":
Expand Down Expand Up @@ -319,6 +324,17 @@ Result:
kind: (string){ "bar" }
}) }
}
issue3411: (struct){
x: (struct){ |(*(struct){
y: (#list){
0: (string){ "bar" }
}
}, (struct){
y: (#list){
0: (string){ "foo" }
}
}) }
}
}
-- diff/-out/evalalpha<==>+out/eval --
diff old new
Expand Down Expand Up @@ -560,6 +576,17 @@ Result:
kind: (string){ "bar" }
}) }
}
issue3411: (struct){
x: (struct){ |(*(struct){
y: (#list){
0: (string){ "bar" }
}
}, (struct){
y: (#list){
0: (string){ "foo" }
}
}) }
}
}
-- out/compile --
--- in.cue
Expand Down Expand Up @@ -762,3 +789,22 @@ Result:
})
}
}
--- issue3411.cue
{
issue3411: {
x: {
y?: [
...string,
]
}
x: ({
y: [
"foo",
]
}|*{
y: [
"bar",
]
})
}
}
1 change: 1 addition & 0 deletions internal/core/adt/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ var skipDebugDepErrors = map[string]int{
"disjunctions/embed": 6,
"disjunctions/errors": 2,
"eval/conjuncts": 3,
"eval/disjunctions": 1,
"eval/issue2146": 4,
"eval/issue599": 1,
"export/031": 1,
Expand Down
2 changes: 0 additions & 2 deletions internal/core/adt/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,6 @@ func (ctx *overlayContext) cloneScheduler(dst, src *nodeContext) {
ds.completed = ss.completed
ds.needs = ss.needs
ds.provided = ss.provided
ds.frozen = ss.frozen
ds.isFrozen = ss.isFrozen
ds.counters = ss.counters

ss.blocking = ss.blocking[:0]
Expand Down

0 comments on commit aeb3bf3

Please sign in to comment.