this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

internal/core/adt: make progression check an assert

This allows the user to turn it off with CUE_DEBUG=0

Often the result will still be somewhat userful, and it
will help debugging as well.

Change-Id: Iaf5cb9045457a9bdd505894d945b93e13dc94b81
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/7905
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>

+5 -7
+2 -3
internal/core/adt/composite.go
··· 246 246 } 247 247 248 248 func (v *Vertex) UpdateStatus(s VertexStatus) { 249 - if v.status > s+1 { 250 - panic(fmt.Sprintf("attempt to regress status from %d to %d", v.Status(), s)) 251 - } 249 + Assertf(v.status <= s+1, "attempt to regress status from %d to %d", v.Status(), s) 250 + 252 251 if s == Finalized && v.BaseValue == nil { 253 252 // panic("not finalized") 254 253 }
+2 -2
internal/core/adt/context.go
··· 43 43 // 44 44 // It is advisable for each use of Assert to document how the error is expected 45 45 // to be handled down the line. 46 - func Assert(name string, b bool) { 46 + func Assertf(b bool, format string, args ...interface{}) { 47 47 if Debug && !b { 48 - panic("assertion failed: " + name) 48 + panic(fmt.Sprintf("assertion failed: "+format, args...)) 49 49 } 50 50 } 51 51
+1 -2
internal/core/eval/eval.go
··· 1746 1746 // TODO: disallow adding conjuncts when cache set? 1747 1747 arc.AddConjunct(x) 1748 1748 1749 - adt.Assert("invalid adt.ID", 1750 - x.CloseID == 0 || int(x.CloseID) < len(closedInfo(n.node).Canopy)) 1749 + adt.Assertf(x.CloseID == 0 || int(x.CloseID) < len(closedInfo(n.node).Canopy), "invalid adt.ID") 1751 1750 1752 1751 if isNew { 1753 1752 closedInfo(n.node).visitAllFieldSets(func(o *fieldSet) {