Skip to content

Commit

Permalink
internal/core/adt: fail earlier on incompatible types
Browse files Browse the repository at this point in the history
This is a big factor in being able to fail earlier.

Issue #2884

Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: I69aeee8c460c5ce766da17298063f56de3d048ab
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1193182
TryBot-Result: CUEcueckoo <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
Reviewed-by: Daniel Martí <[email protected]>
  • Loading branch information
mpvl committed Apr 18, 2024
1 parent 517f611 commit 6728bb2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
28 changes: 14 additions & 14 deletions cue/testdata/benchmarks/issue1684.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ nestedClosed: passing: {
D: {id: {}} | {[string]: D}
}
-- out/evalalpha/stats --
Leaks: 5097
Freed: 1396
Reused: 1396
Allocs: 5097
Leaks: 2533
Freed: 612
Reused: 612
Allocs: 2533
Retain: 0

Unifications: 1831
Conjuncts: 13300
Disjuncts: 2526
Unifications: 707
Conjuncts: 5878
Disjuncts: 1102
-- out/evalalpha --
(struct){
#Secret: (#struct){
Expand Down Expand Up @@ -149,18 +149,18 @@ diff old new
-Freed: 1064333
-Reused: 1064282
-Allocs: 51
+Leaks: 5097
+Freed: 1396
+Reused: 1396
+Allocs: 5097
+Leaks: 2533
+Freed: 612
+Reused: 612
+Allocs: 2533
Retain: 0

-Unifications: 792123
-Conjuncts: 2480117
-Disjuncts: 1064333
+Unifications: 1831
+Conjuncts: 13300
+Disjuncts: 2526
+Unifications: 707
+Conjuncts: 5878
+Disjuncts: 1102
-- diff/-out/evalalpha<==>+out/eval --
diff old new
--- old
Expand Down
2 changes: 1 addition & 1 deletion internal/core/adt/disjunct2.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ func (n *nodeContext) finalizeDisjunctions() {
}

func (n *nodeContext) getError() *Bottom {
if b, ok := n.node.BaseValue.(*Bottom); ok {
if b, ok := n.node.BaseValue.(*Bottom); ok && !isCyclePlaceholder(b) {
return b
}
if n.node.ChildErrors != nil {
Expand Down
7 changes: 4 additions & 3 deletions internal/core/adt/unify.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ func (v *Vertex) unify(c *OpContext, needs condition, mode runMode) bool {
}
n.updateScalar()

if n.aStruct != nil {
n.updateNodeType(StructKind, n.aStruct, n.aStructID)
}

// First process all but the subfields.
switch {
case n.meets(nodeOnlyNeeds):
Expand All @@ -199,9 +203,6 @@ func (v *Vertex) unify(c *OpContext, needs condition, mode runMode) bool {
if isCyclePlaceholder(n.node.BaseValue) {
n.node.BaseValue = nil
}
if n.aStruct != nil {
n.updateNodeType(StructKind, n.aStruct, n.aStructID)
}

// TODO: rewrite to use mode when we get rid of old evaluator.
state := finalized
Expand Down

0 comments on commit 6728bb2

Please sign in to comment.