this repo has no description
0
fork

Configure Feed

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

cmd/cue: remove support for CUE_DEBUG_SORT_ARCS

This fairly old debugging flag worked on the old evaluator but never
worked on the new evaluator; we instead focused on a new field ordering
available for both versions via CUE_EXPERIMENT=toposort, which should
be enabled by default very soon, as well as a lexicographical ordering
available for now under CUE_DEBUG=sortfields.

Given that CUE_DEBUG_SORT_ARCS was never meant for end users nor
properly documented, that it never worked for evalv3, and that we now
have the two new field ordering mechanisms which work on both evaluator
versions, it's time to delete this code for v0.12.0-alpha.1.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Ic02403693c871608929b65d4b019432e8a81c849
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1205985
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Matthew Sackman <matthew@cue.works>

+13 -74
-4
cmd/cue/cmd/common.go
··· 19 19 "os" 20 20 "path/filepath" 21 21 "regexp" 22 - "strconv" 23 22 "strings" 24 23 25 24 "github.com/spf13/pflag" ··· 33 32 "cuelang.org/go/cue/parser" 34 33 "cuelang.org/go/cue/token" 35 34 "cuelang.org/go/internal" 36 - "cuelang.org/go/internal/core/adt" 37 35 "cuelang.org/go/internal/encoding" 38 36 "cuelang.org/go/internal/filetypes" 39 37 ) ··· 503 501 if err != nil { 504 502 return nil, err 505 503 } 506 - 507 - adt.DebugSort, _ = strconv.Atoi(os.Getenv("CUE_DEBUG_SORT_ARCS")) 508 504 509 505 builds := loadFromArgs(args, cfg.loadCfg) 510 506 if builds == nil {
-42
internal/core/adt/context.go
··· 19 19 "log" 20 20 "reflect" 21 21 "regexp" 22 - "sort" 23 22 "strings" 24 23 25 24 "github.com/cockroachdb/apd/v3" ··· 32 31 "cuelang.org/go/internal" 33 32 "cuelang.org/go/internal/cuedebug" 34 33 ) 35 - 36 - // DebugSort specifies that arcs be sorted consistently between implementations. 37 - // 38 - // 0: default 39 - // 1: sort by Feature: this should be consistent between implementations where 40 - // there is no change in the compiler and indexing code. 41 - // 2: alphabetical 42 - // 43 - // TODO: move to DebugFlags 44 - var DebugSort int 45 - 46 - func DebugSortArcs(c *OpContext, n *Vertex) { 47 - if n.IsList() { 48 - return 49 - } 50 - switch a := n.Arcs; DebugSort { 51 - case 1: 52 - sort.SliceStable(a, func(i, j int) bool { 53 - return a[i].Label < a[j].Label 54 - }) 55 - case 2: 56 - sort.SliceStable(a, func(i, j int) bool { 57 - return a[i].Label.SelectorString(c.Runtime) < 58 - a[j].Label.SelectorString(c.Runtime) 59 - }) 60 - } 61 - } 62 - 63 - func DebugSortFields(c *OpContext, a []Feature) { 64 - switch DebugSort { 65 - case 1: 66 - sort.SliceStable(a, func(i, j int) bool { 67 - return a[i] < a[j] 68 - }) 69 - case 2: 70 - sort.SliceStable(a, func(i, j int) bool { 71 - return a[i].SelectorString(c.Runtime) < 72 - a[j].SelectorString(c.Runtime) 73 - }) 74 - } 75 - } 76 34 77 35 // Assert panics if the condition is false. Assert can be used to check for 78 36 // conditions that are considers to break an internal variant or unexpected
-4
internal/core/adt/eval.go
··· 809 809 func (n *nodeContext) completeArcs(state vertexStatus) { 810 810 unreachableForDev(n.ctx) 811 811 812 - if DebugSort > 0 { 813 - DebugSortArcs(n.ctx, n.node) 814 - } 815 - 816 812 if n.node.hasAllConjuncts || n.node.Parent == nil { 817 813 n.node.setParentDone() 818 814 }
-4
internal/core/adt/unify.go
··· 250 250 // done 251 251 252 252 case needs&subFieldsProcessed != 0: 253 - if DebugSort > 0 { 254 - DebugSortArcs(n.ctx, n.node) 255 - } 256 - 257 253 switch { 258 254 case assertStructuralCycleV3(n): 259 255 // TODO: consider bailing on error if n.errs != nil.
+9 -13
internal/core/export/expr.go
··· 189 189 return -cmp.Compare(f1, f2) 190 190 }) 191 191 192 - if adt.DebugSort == 0 { 193 - m := sortArcs(extractFeatures(e.structs)) 194 - slices.SortStableFunc(fields, func(f1, f2 adt.Feature) int { 195 - if m[f2] == 0 { 196 - if m[f1] == 0 { 197 - return +1 198 - } 199 - return -1 192 + m := sortArcs(extractFeatures(e.structs)) 193 + slices.SortStableFunc(fields, func(f1, f2 adt.Feature) int { 194 + if m[f2] == 0 { 195 + if m[f1] == 0 { 196 + return +1 200 197 } 201 - return -cmp.Compare(m[f1], m[f2]) 202 - }) 203 - } else { 204 - adt.DebugSortFields(e.ctx, fields) 205 - } 198 + return -1 199 + } 200 + return -cmp.Compare(m[f1], m[f2]) 201 + }) 206 202 207 203 if len(e.fields) == 0 && !e.hasEllipsis { 208 204 switch len(e.embed) + len(e.conjuncts) {
+3 -7
internal/core/export/toposort.go
··· 32 32 if c.TopoSort { 33 33 return toposort.VertexFeatures(c, v) 34 34 } else { 35 - return vertexFeatures(c, v) 35 + return vertexFeatures(v) 36 36 } 37 37 } 38 38 39 - func vertexFeatures(c *adt.OpContext, v *adt.Vertex) []adt.Feature { 39 + func vertexFeatures(v *adt.Vertex) []adt.Feature { 40 40 sets := extractFeatures(v.Structs) 41 41 m := sortArcs(sets) // TODO: use for convenience. 42 42 ··· 54 54 sets = append(sets, a) 55 55 } 56 56 57 - a = sortedArcs(sets) 58 - if adt.DebugSort > 0 { 59 - adt.DebugSortFields(c, a) 60 - } 61 - return a 57 + return sortedArcs(sets) 62 58 } 63 59 64 60 func extractFeatures(in []*adt.StructInfo) (a [][]adt.Feature) {
+1
tools/flow/flow.go
··· 90 90 // TODO: ErrUpdate: update and run a dependency, but don't complete a 91 91 // dependency as more results may come. This is useful in server mode. 92 92 93 + // TODO: move CUE_DEBUG_TOOLS_FLOW=1 to e.g. CUE_DEBUG=toolsflow 93 94 debug = os.Getenv("CUE_DEBUG_TOOLS_FLOW") != "" 94 95 ) 95 96