diff --git a/cmd/cue/cmd/testdata/script/issue526.txt b/cmd/cue/cmd/testdata/script/issue526.txt new file mode 100644 index 000000000..a226171fd --- /dev/null +++ b/cmd/cue/cmd/testdata/script/issue526.txt @@ -0,0 +1,12 @@ +cue cmd gengithub + +-- x.cue -- +package x + +test: #Workflow +#Workflow: 1 | [_] + +-- x_tool.cue -- +package x + +command: gengithub: {} diff --git a/internal/core/adt/composite.go b/internal/core/adt/composite.go index bb63010f8..5dfaa126c 100644 --- a/internal/core/adt/composite.go +++ b/internal/core/adt/composite.go @@ -279,17 +279,50 @@ func (v *Vertex) ToDataAll() *Vertex { arcs[i] = a.ToDataAll() } w := *v + + w.Value = toDataAll(w.Value) w.Arcs = arcs w.isData = true w.Conjuncts = make([]Conjunct, len(v.Conjuncts)) copy(w.Conjuncts, v.Conjuncts) - for i := range w.Conjuncts { + for i, c := range w.Conjuncts { w.Conjuncts[i].CloseID = 0 + if v, _ := c.x.(Value); v != nil { + w.Conjuncts[i].x = toDataAll(v) + } } w.Closed = nil return &w } +func toDataAll(v Value) Value { + switch x := v.(type) { + default: + return x + + case *Vertex: + return x.ToDataAll() + + // The following cases are always erroneous, but we handle them anyway + // to avoid issues with the closedness algorithm down the line. + case *Disjunction: + d := *x + d.Values = make([]*Vertex, len(x.Values)) + for i, v := range x.Values { + d.Values[i] = v.ToDataAll() + } + return &d + + case *Conjunction: + c := *x + c.Values = make([]Value, len(x.Values)) + for i, v := range x.Values { + c.Values[i] = toDataAll(v) + } + return &c + } +} + // func (v *Vertex) IsEvaluating() bool { // return v.Value == cycle // } @@ -314,9 +347,6 @@ func (v *Vertex) Err(c *OpContext, state VertexStatus) *Bottom { // func (v *Vertex) Evaluate() func (v *Vertex) Finalize(c *OpContext) { - if c == nil { - fmt.Println("WOT?") - } c.Unify(c, v, Finalized) }