Skip to content

Commit

Permalink
Ugly fix for #2500 issue
Browse files Browse the repository at this point in the history
  • Loading branch information
bozaro committed Jul 26, 2023
1 parent 31166ba commit cd72a6e
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 193 deletions.
219 changes: 33 additions & 186 deletions cue/testdata/benchmarks/issue2500.txtar

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions cue/testdata/comprehensions/iferror.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ Leaks: 0
Freed: 43
Reused: 35
Allocs: 8
Retain: 22
Retain: 20

Unifications: 33
Conjuncts: 68
Disjuncts: 60
Disjuncts: 59
-- out/eval --
Errors:
issue1972.err1: conflicting values [] and {someCondition:_,patchs:[...{}],patchs,if someCondition {patchs:_}} (mismatched types list and struct):
Expand Down
4 changes: 2 additions & 2 deletions cue/testdata/cycle/023_reentrance.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ Leaks: 16
Freed: 180
Reused: 169
Allocs: 27
Retain: 224
Retain: 221

Unifications: 196
Conjuncts: 464
Disjuncts: 292
Disjuncts: 289
-- out/eval --
Errors:
structural cycle:
Expand Down
5 changes: 5 additions & 0 deletions internal/core/adt/comprehension.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@ func (n *nodeContext) injectComprehensions(state vertexStatus) (progress bool) {
d.err = err
workRemaining = true

if n.ctx.IsIncompleteCheck && err.IsIncomplete() {
n.addBottom(err)
break
}

continue

// TODO: add this when it can be done without breaking other
Expand Down
19 changes: 19 additions & 0 deletions internal/core/adt/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ type OpContext struct {
// as an error if this is true.
// TODO: strictly separate validators and functions.
IsValidator bool

// Use fail fast mode to incomplete check.
IsIncompleteCheck bool
}

func (c *OpContext) CloseInfo() CloseInfo { return c.ci }
Expand Down Expand Up @@ -399,6 +402,22 @@ type frame struct {
ci CloseInfo
}

type frameIncomplete struct {
incompleteCheck bool
}

func (c *OpContext) PushIncompleteCheck() frameIncomplete {
saved := frameIncomplete{
incompleteCheck: c.IsIncompleteCheck,
}
c.IsIncompleteCheck = true
return saved
}

func (c *OpContext) PopIncompleteCheck(s frameIncomplete) {
c.IsIncompleteCheck = s.incompleteCheck
}

func (c *OpContext) PushState(env *Environment, src ast.Node) (saved frame) {
saved.env = c.e
saved.err = c.errs
Expand Down
8 changes: 6 additions & 2 deletions internal/core/adt/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,12 @@ func (n *nodeContext) postDisjunct(state vertexStatus) {
n.injectSelfComprehensions(state)
}

for n.expandOne(state) {
}
func() {
stack := n.ctx.PushIncompleteCheck()
defer n.ctx.PopIncompleteCheck(stack)
for n.expandOne(state) {
}
}()

switch err := n.getErr(); {
case err != nil:
Expand Down
2 changes: 1 addition & 1 deletion internal/core/export/testdata/main/simplify.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ additional: {
s: strings.MinRunes(4) & strings.MaxRunes(7)
additional: {
env: _
confs: _|_ // additional.confs: incomplete bool: _ (and 2 more errors)
confs: _|_ // additional.confs: incomplete bool: _
}
}
== All
Expand Down

0 comments on commit cd72a6e

Please sign in to comment.