cue: don't turn of manifesting in normalization

The problem is that the cached results of partially
evaluated values end can cause spurious "incomplete"
errors later in evaluation.

The orignal comment as to why this was done does
not (any longer) apply: referenced structs are always
copied with a cleared cache. So it is safe to cache the
values now.

Change-Id: Ic79e0231190ca3c2c017a8850d236f01509fbbd7
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/3960
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cue/context.go b/cue/context.go
index 29c50a1..947987d 100644
--- a/cue/context.go
+++ b/cue/context.go
@@ -35,8 +35,6 @@
 	inSum        int
 	cycleErr     bool
 
-	noManifest bool
-
 	// for debug strings
 	nodeRefs map[scope]string
 
diff --git a/cue/evaluator.go b/cue/evaluator.go
index 48ff71c..703879a 100644
--- a/cue/evaluator.go
+++ b/cue/evaluator.go
@@ -16,9 +16,6 @@
 
 func (c *context) manifest(v value) evaluated {
 	evaluated := v.evalPartial(c)
-	if c.noManifest {
-		return evaluated
-	}
 outer:
 	switch x := evaluated.(type) {
 	case *disjunction:
diff --git a/cue/resolve_test.go b/cue/resolve_test.go
index d913702..1c3ee9f 100644
--- a/cue/resolve_test.go
+++ b/cue/resolve_test.go
@@ -2733,6 +2733,23 @@
 			`c: <9>C{C{[=~"^Q*$"]: <10>(_: string)->int}, C{(C{[=~"^[a-s]*$"]: <11>(_: string)->int} & C{[=~"^[m-z]*?"]: <12>(_: string)->int})}, QQ: 3}, ` +
 			`D :: <13>C{[=~"^[a-s]*$"]: <14>(_: string)->int, [=~"^[m-z]*?"]: <15>(_: string)->int, }, ` +
 			`d: <16>C{[=~"^[a-s]*$"]: <17>(_: string)->int, [=~"^[m-z]*?"]: <18>(_: string)->int, aaa: 4}}`,
+	}, {
+		in: `
+		Task :: {
+			{
+				op:          "pull"
+				tag:         *"latest" | string
+				refToTag:    tag
+				tagExpr: tag + "dd"
+				tagInString: "\(tag)"
+			} | {
+				op: "scratch"
+			}
+		}
+
+		foo: Task & {"op": "pull"}
+		`,
+		out: `<0>{Task :: (<1>C{op: "pull", tag: (*"latest" | string), refToTag: <1>.tag, tagExpr: (<1>.tag + "dd"), tagInString: ""+<1>.tag+""} | <2>C{op: "scratch"}), foo: <3>C{op: "pull", tag: "latest", refToTag: "latest", tagExpr: "latestdd", tagInString: "latest"}}`,
 	}}
 	rewriteHelper(t, testCases, evalFull)
 }
diff --git a/cue/types_test.go b/cue/types_test.go
index 0b7dcd7..31eb4a6 100644
--- a/cue/types_test.go
+++ b/cue/types_test.go
@@ -1843,6 +1843,21 @@
 		f: >=1.1 & <=1.1
 		`,
 		json: `{"a":1,"b":1,"c":2,"d":1,"e":1,"f":1.1}`,
+	}, {
+		value: `
+		Task :: {
+			{
+				op:          "pull"
+				tag:         *"latest" | string
+				tagInString: tag + "dd"
+			} | {
+				op: "scratch"
+			}
+		}
+
+		foo: Task & {"op": "pull"}
+		`,
+		json: `{"foo":{"op":"pull","tag":"latest","tagInString":"latestdd"}}`,
 	}}
 	for i, tc := range testCases {
 		t.Run(fmt.Sprintf("%d/%v", i, tc.value), func(t *testing.T) {
diff --git a/cue/value.go b/cue/value.go
index 27aeb7e..7ad98e7 100644
--- a/cue/value.go
+++ b/cue/value.go
@@ -1624,11 +1624,6 @@
 	}
 	k := 0
 
-	// manifesting values should be disabled for recursive evaluation as
-	// these values may still be bound to another value later on, for instance
-	// when the result of this value is unified with another value.
-	noManifest := ctx.noManifest
-	ctx.noManifest = true
 	hasMarked := false
 	var markedErr *bottom
 outer:
@@ -1673,7 +1668,6 @@
 		x.values[k] = dValue{&bottom{}, true}
 		k++
 	}
-	ctx.noManifest = noManifest
 
 	switch k {
 	case 0: