cue: allow cyclic references in lists

This is done by making lists considerably less efficient,
but that is for later concern. Still better, probably,
than creating a linked list.

Errors are now retained at the value level within lists.
This is okay, as validation descends into list values
as well.

Change-Id: Ifcd35d383f061dab82164d8da36f693dbea64847
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/1900
Reviewed-by: Marcel van Lohuizen <mpvl@google.com>
diff --git a/cue/ast.go b/cue/ast.go
index 5246b30..6d6e8fa 100644
--- a/cue/ast.go
+++ b/cue/ast.go
@@ -421,10 +421,12 @@
 		}
 
 	case *ast.ListLit:
-		list := &list{baseValue: newExpr(n)}
-		for _, e := range n.Elts {
-			list.a = append(list.a, v.walk(e))
+		arcs := []arc{}
+		for i, e := range n.Elts {
+			arcs = append(arcs, arc{feature: label(i), v: v.walk(e)})
 		}
+		s := &structLit{baseValue: newExpr(n), arcs: arcs}
+		list := &list{baseValue: newExpr(n), elem: s}
 		list.initLit()
 		if n.Ellipsis != token.NoPos || n.Type != nil {
 			list.len = &bound{list.baseValue, opGeq, list.len}