Skip to content

Commit

Permalink
internal/core/adt: fix closedness issue related to sharing
Browse files Browse the repository at this point in the history
A closedness issue could arise when a vertex
was unified multiple times within the same
node if this vertex was (initially) shared.
Basically, the when a shared node was
added again, it was dropped based on pointer
equivalence. If then later this node was
unshared, this node was no longer added,
meaning that arcs could be missing from
closedness information, causing arcs to be
incorrectly defined as missing.

We now ensure the node is added multiple
times, just like when structure sharing is off,
to ensure closedness data is correctly
computed.

Note that this also fixes issue 3527. This
was not marked as problematic, as the
original CL just fixed the panic. But the
result was still incorrect.

Fixes #3641
Fixes #3546
Issue #3527

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I9c248b0448ae1bcfcf4e4c1832397d73e8b02705
Dispatch-Trailer: {"type":"trybot","CL":1206823,"patchset":1,"ref":"refs/changes/23/1206823/1","targetBranch":"master"}
  • Loading branch information
mpvl authored and cueckoo committed Jan 7, 2025
1 parent aab844f commit 009664d
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 322 deletions.
87 changes: 22 additions & 65 deletions cue/testdata/cycle/issue3527.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -30,44 +30,29 @@ Unifications: 35
Conjuncts: 82
Disjuncts: 39
-- out/evalalpha --
Errors:
assert.res._computed.in.taxPayer.self: field not allowed:
./in.cue:5:22
./in.cue:18:12

Result:
(_|_){
// [eval]
(struct){
_taxPayer(:p): (struct){
self: (struct){
}
}
let sam#1 = (struct){
taxPayer: ~(_taxPayer(:p))
}
assert: (_|_){
// [eval]
assert: (struct){
invoke: (struct){
taxPayer: ~(_taxPayer(:p))
}
res: (_|_){
// [eval]
res: (struct){
in: (#struct){
taxPayer: (#struct){
self: (#struct){
}
}
}
_computed(:p): (_|_){
// [eval]
in: (_|_){
// [eval]
taxPayer: (_|_){
// [eval]
self: (_|_){
// [eval] assert.res._computed.in.taxPayer.self: field not allowed:
// ./in.cue:5:22
// ./in.cue:18:12
_computed(:p): (#struct){
in: (#struct){
taxPayer: (#struct){
self: (#struct){
}
}
}
Expand All @@ -94,70 +79,42 @@ Result:
diff old new
--- old
+++ new
@@ -1,32 +1,41 @@
-(struct){
+Errors:
+assert.res._computed.in.taxPayer.self: field not allowed:
+ ./in.cue:5:22
+ ./in.cue:18:12
+
+Result:
+(_|_){
+ // [eval]
_taxPayer(:p): (struct){
self: (struct){
@@ -4,22 +4,16 @@
}
}
let sam#1 = (struct){
- taxPayer: (struct){
- self: (struct){
- }
- }
- }
- assert: (struct){
+ taxPayer: ~(_taxPayer(:p))
+ }
+ assert: (_|_){
+ // [eval]
}
assert: (struct){
invoke: (struct){
- taxPayer: (struct){
- self: (struct){
- }
- }
- }
- res: (struct){
+ taxPayer: ~(_taxPayer(:p))
+ }
+ res: (_|_){
+ // [eval]
}
res: (struct){
in: (#struct){
taxPayer: (#struct){
- self: (struct){
- }
- }
- }
- _computed(:p): (#struct){
- in: (#struct){
- taxPayer: (#struct){
- self: (struct){
+ self: (#struct){
+ }
+ }
+ }
+ _computed(:p): (_|_){
+ // [eval]
+ in: (_|_){
+ // [eval]
+ taxPayer: (_|_){
+ // [eval]
+ self: (_|_){
+ // [eval] assert.res._computed.in.taxPayer.self: field not allowed:
+ // ./in.cue:5:22
+ // ./in.cue:18:12
}
}
}
@@ -26,7 +20,7 @@
_computed(:p): (#struct){
in: (#struct){
taxPayer: (#struct){
- self: (struct){
+ self: (#struct){
}
}
}
@@ -34,30 +43,16 @@
@@ -34,30 +28,16 @@
}
}
subject: (struct){
Expand Down
Loading

0 comments on commit 009664d

Please sign in to comment.