Skip to content

Commit

Permalink
internal/core/adt: fix some regressions
Browse files Browse the repository at this point in the history
- Mark Evaluating before reprocessing Partial
This avoids a stack overflow.

- Don't finalize too early
It is important to not finalize nodes too early, as
this may result in insertions being ignored. In the
old implementation these bugs were missed as it
did a lot of extraneous recomputation.

- Fix "Finalized" forcing of disjunctions
When expanding disjunctions, only the last in a
sequence should be marked as finalized. The logic
here was flawed and would also tag the final
disjuncts of mid-stream subdisjunctions as final.

- As Resolve no longer finalizes, the cue API now
needs to finalize things itself.

- Ensure ToData does not leave dangling state
The state should always be Finalized, but just
in case.

Fixes #633

Change-Id: Ia6bd0b3bebb25c9033a30d3513b26b96454d0b91
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/8141
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
  • Loading branch information
mpvl committed Jan 15, 2021
1 parent 237a4ae commit 34a91b9
Show file tree
Hide file tree
Showing 9 changed files with 325 additions and 120 deletions.
117 changes: 117 additions & 0 deletions cue/testdata/builtins/closed.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ a: close({
b: a & { x: int } // err
c: a & { a: c: int } // okay (non-recursive close)

inDisjunctions: {
x: [string]: #Def
#Def: [string]: {
a: b: true
let X = a
close({uint: a: b: X.b}) | close({string: a: b: true})
}
x: socket: string: {}
x: syslog: x.socket
x: syslog: xxx: {}
}

-- out/eval --
Errors:
b: field `x` not allowed:
Expand Down Expand Up @@ -39,6 +51,73 @@ Result:
c: (int){ int }
}
}
inDisjunctions: (struct){
x: (struct){
socket: (#struct){
string: (struct){ |((#struct){
a: (#struct){
b: (bool){ true }
}
uint: (#struct){
a: (#struct){
b: (bool){ true }
}
}
}, (#struct){
a: (#struct){
b: (bool){ true }
}
string: (#struct){
a: (#struct){
b: (bool){ true }
}
}
}) }
}
syslog: (#struct){
string: (struct){ |((#struct){
a: (#struct){
b: (bool){ true }
}
uint: (#struct){
a: (#struct){
b: (bool){ true }
}
}
}, (#struct){
a: (#struct){
b: (bool){ true }
}
string: (#struct){
a: (#struct){
b: (bool){ true }
}
}
}) }
xxx: (struct){ |((#struct){
a: (#struct){
b: (bool){ true }
}
uint: (#struct){
a: (#struct){
b: (bool){ true }
}
}
}, (#struct){
a: (#struct){
b: (bool){ true }
}
string: (#struct){
a: (#struct){
b: (bool){ true }
}
}
}) }
}
}
#Def: (#struct){
}
}
}
-- out/compile --
--- in.cue
Expand All @@ -56,4 +135,42 @@ Result:
c: int
}
})
inDisjunctions: {
x: {
[string]: 〈1;#Def〉
}
#Def: {
[string]: {
a: {
b: true
}
(close({
uint: {
a: {
b: 〈3;let X〉.b
}
}
})|close({
string: {
a: {
b: true
}
}
}))
}
}
x: {
socket: {
string: {}
}
}
x: {
syslog: 〈1;x〉.socket
}
x: {
syslog: {
xxx: {}
}
}
}
}

0 comments on commit 34a91b9

Please sign in to comment.