internal/core/export: don't embed proper conjuncts

This now makes the distinction between conjuncts
and embeddings, fixing a bug that resulted from the
slight semantics changes in embeddings introduced in
https://cue-review.googlesource.com/c/cue/+/8229

Note that scalar values can still always be embedded
as it doesn't affect closedness.
Also recersively nested embeddings can be merged.
Nested closed conjunctions need to remain conjunctions.

Change-Id: I14c1a30802132effe0c6c27a4a8e363236df5771
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/8363
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/internal/core/export/expr.go b/internal/core/export/expr.go
index 97c63db..9673e48 100644
--- a/internal/core/export/expr.go
+++ b/internal/core/export/expr.go
@@ -97,7 +97,7 @@
 	for _, c := range a {
 		e.top().upCount = c.up
 		x := c.c.Expr()
-		e.addExpr(c.c.Env, x)
+		e.addExpr(c.c.Env, x, false)
 	}
 
 	s := x.top().scope
@@ -109,7 +109,7 @@
 	// Unify values only for one level.
 	if len(e.values.Conjuncts) > 0 {
 		e.values.Finalize(e.ctx)
-		e.exprs = append(e.exprs, e.value(e.values, e.values.Conjuncts...))
+		e.embed = append(e.embed, e.value(e.values, e.values.Conjuncts...))
 	}
 
 	// Collect and order set of fields.
@@ -135,21 +135,25 @@
 	})
 
 	if len(e.fields) == 0 && !e.hasEllipsis {
-		switch len(e.exprs) {
+		switch len(e.embed) + len(e.conjuncts) {
 		case 0:
 			if len(e.structs) > 0 {
 				return s
 			}
 			return ast.NewIdent("_")
 		case 1:
-			return e.exprs[0]
+			if len(e.conjuncts) == 1 {
+				return e.conjuncts[0]
+			}
+			return e.embed[0]
 		case 2:
 			// Simplify.
-			return ast.NewBinExpr(token.AND, e.exprs...)
+			e.conjuncts = append(e.conjuncts, e.embed...)
+			return ast.NewBinExpr(token.AND, e.conjuncts...)
 		}
 	}
 
-	for _, x := range e.exprs {
+	for _, x := range e.embed {
 		s.Elts = append(s.Elts, &ast.EmbedDecl{Expr: x})
 	}
 
@@ -201,7 +205,9 @@
 		return ast.NewCall(ast.NewIdent("close"), s)
 	}
 
-	return s
+	e.conjuncts = append(e.conjuncts, s)
+
+	return ast.NewBinExpr(token.AND, e.conjuncts...)
 }
 
 // Conjuncts if for collecting values of a single vertex.
@@ -209,7 +215,8 @@
 	*exporter
 	// Values is used to collect non-struct values.
 	values      *adt.Vertex
-	exprs       []ast.Expr
+	embed       []ast.Expr
+	conjuncts   []ast.Expr
 	structs     []*adt.StructInfo
 	fields      map[adt.Feature]field
 	attrs       []*ast.Attribute
@@ -238,7 +245,7 @@
 	up int32
 }
 
-func (e *conjuncts) addExpr(env *adt.Environment, x adt.Expr) {
+func (e *conjuncts) addExpr(env *adt.Environment, x adt.Expr, isEmbed bool) {
 	switch x := x.(type) {
 	case *adt.StructLit:
 		e.top().upCount++
@@ -250,7 +257,7 @@
 		// Only add if it only has no bulk fields or elipsis.
 		if isComplexStruct(x) {
 			_, saved := e.pushFrame(nil)
-			e.exprs = append(e.exprs, e.adt(x, nil))
+			e.embed = append(e.embed, e.adt(x, nil))
 			e.popFrame(saved)
 			return
 		}
@@ -269,7 +276,7 @@
 				e.hasEllipsis = true
 				continue
 			case adt.Expr:
-				e.addExpr(env, f)
+				e.addExpr(env, f, true)
 				continue
 
 				// TODO: also handle dynamic fields
@@ -301,7 +308,7 @@
 					v.MatchAndInsert(e.ctx, v)
 					a = append(a, &ast.Ellipsis{Type: e.expr(v)})
 				}
-				e.exprs = append(e.exprs, ast.NewList(a...))
+				e.embed = append(e.embed, ast.NewList(a...))
 				return
 
 			case *adt.StructMarker:
@@ -322,20 +329,27 @@
 
 	case *adt.BinaryExpr:
 		switch {
-		case x.Op == adt.AndOp:
-			e.addExpr(env, x.X)
-			e.addExpr(env, x.Y)
+		case x.Op == adt.AndOp && !isEmbed:
+			e.addExpr(env, x.X, false)
+			e.addExpr(env, x.Y, false)
 		case isSelfContained(x):
 			e.values.AddConjunct(adt.MakeRootConjunct(env, x))
 		default:
-			e.exprs = append(e.exprs, e.expr(x))
+			if isEmbed {
+				e.embed = append(e.embed, e.expr(x))
+			} else {
+				e.conjuncts = append(e.conjuncts, e.expr(x))
+			}
 		}
 
 	default:
-		if isSelfContained(x) {
+		switch {
+		case isSelfContained(x):
 			e.values.AddConjunct(adt.MakeRootConjunct(env, x))
-		} else {
-			e.exprs = append(e.exprs, e.expr(x))
+		case isEmbed:
+			e.embed = append(e.embed, e.expr(x))
+		default:
+			e.conjuncts = append(e.conjuncts, e.expr(x))
 		}
 	}
 }
diff --git a/internal/core/export/testdata/adt.txtar b/internal/core/export/testdata/adt.txtar
index 5b701fe..9adb227 100644
--- a/internal/core/export/testdata/adt.txtar
+++ b/internal/core/export/testdata/adt.txtar
@@ -28,6 +28,18 @@
 l2: [...int]
 l3: []
 l4: [1, 2]
+l5: [1, 3] & {
+	[1, 3]
+
+	#foo: int
+}
+
+#foo: int
+l6: [1, #foo] & {
+	[1, 3]
+
+	#foo: int
+}
 
 n1: 1.0
 n10: 10
@@ -48,9 +60,9 @@
 e7: !t || !false
 e8?: !false
 
-m1: {
+m1: {[string]: uint} & {
     // this is a pattern constraint
-    {[string]: int}
+    {[string]: int} & {[string]: int64}
     // foo is an optional field
     foo?: 3
 
@@ -134,6 +146,15 @@
 l2: [...int]
 l3: []
 l4: [1, 2]
+l5: [1, 3] & {
+	[1, 3]
+	#foo: int
+}
+#foo: int
+l6:   [1, #foo] & {
+	[1, 3]
+	#foo: int
+}
 n1:  1.0
 n10: 10
 t:   true
@@ -145,9 +166,13 @@
 e6:  !t
 e7:  !t || !false
 e8?: !false
-m1: {
+m1:  {
+	[string]: int & >=0
+} & {
 	{
 		[string]: int
+	} & {
+		[string]: int64
 	}
 
 	// foo is an optional field
@@ -205,6 +230,15 @@
 [l4]
 [l4 0]
 [l4 1]
+[l5]
+[l5 #foo]
+[l5 0]
+[l5 1]
+[#foo]
+[l6]
+[l6 #foo]
+[l6 0]
+[l6 1]
 [n1]
 [n10]
 [t]
@@ -281,6 +315,15 @@
 	l2: []
 	l3: []
 	l4: [1, 2]
+	l5: {
+		#foo: int
+		[1, 3]
+	}
+	#foo: int
+	l6: {
+		#foo: int
+		[1, 3]
+	}
 	n1:  1.0
 	n10: 10
 
diff --git a/internal/core/export/testdata/docs.txtar b/internal/core/export/testdata/docs.txtar
index c8ad5bb..814b9f7 100644
--- a/internal/core/export/testdata/docs.txtar
+++ b/internal/core/export/testdata/docs.txtar
@@ -126,9 +126,7 @@
 	// comment from bar on field 2
 	field2: int
 }
-baz: {
-	bar
-
+baz: bar & {
 	// comment from baz on field 1
 	field1: int
 	field2: int
diff --git a/internal/core/export/testdata/hidden.txtar b/internal/core/export/testdata/hidden.txtar
index 644139c..c3ee85a 100644
--- a/internal/core/export/testdata/hidden.txtar
+++ b/internal/core/export/testdata/hidden.txtar
@@ -22,8 +22,7 @@
 
 import "acme.com/pkg"
 
-a: {
-	pkg.#A
+a: pkg.#A & {
 	_val:  3
 	_#val: 6
 }
diff --git a/internal/core/export/testdata/issue662.txtar b/internal/core/export/testdata/issue662.txtar
index ff9a2be..0f23548 100644
--- a/internal/core/export/testdata/issue662.txtar
+++ b/internal/core/export/testdata/issue662.txtar
@@ -11,8 +11,7 @@
 #LineConfig: {
 	lineColor?: string
 }
-#GraphFieldConfig: {
-	#LineConfig
+#GraphFieldConfig: #LineConfig & {
 	drawStyle?: int
 }
 -- out/doc --
diff --git a/internal/core/export/testdata/merge.txtar b/internal/core/export/testdata/merge.txtar
new file mode 100644
index 0000000..5e0121d
--- /dev/null
+++ b/internal/core/export/testdata/merge.txtar
@@ -0,0 +1,102 @@
+-- in.cue --
+#A: {
+    _
+	#a: string
+}
+
+#E: {_}
+#F: {_}
+#G: {_}
+
+#B: #A & {
+	{ 2, #def: 3 }
+	2
+	#E & #F
+	#f: int
+    {
+        _
+        #bar: int
+        #G
+    }
+
+}
+-- out/definition --
+#A: {
+	#a: string
+}
+#E: {}
+#F: {}
+#G: {}
+#B: #A & {
+	#E & #F
+	#G
+	2
+	#f:   int
+	#def: 3
+	#bar: int
+}
+-- out/doc --
+[]
+[#A]
+[#A #a]
+[#E]
+[#F]
+[#G]
+[#B]
+[#B #a]
+[#B #def]
+[#B #bar]
+[#B #f]
+-- out/value --
+== Simplified
+{}
+== Raw
+{
+	#A: {
+		#a: string
+	}
+	#E: {}
+	#F: {}
+	#G: {}
+	#B: {
+		2
+		#a:   string
+		#f:   int
+		#def: 3
+		#bar: int
+	}
+}
+== Final
+{}
+== All
+{
+	#A: {
+		#a: string
+	}
+	#E: {}
+	#F: {}
+	#G: {}
+	#B: {
+		2
+		#a:   string
+		#f:   int
+		#def: 3
+		#bar: int
+	}
+}
+== Eval
+{
+	#A: {
+		#a: string
+	}
+	#E: {}
+	#F: {}
+	#G: {}
+	#B: {
+		2
+		#a:   string
+		#f:   int
+		#def: 3
+		#bar: int
+	}
+}
diff --git a/internal/filetypes/types.go b/internal/filetypes/types.go
index ec5e6db..e554ebf 100644
--- a/internal/filetypes/types.go
+++ b/internal/filetypes/types.go
@@ -41,5 +41,5 @@
 	return v
 }
 
-// Data size: 1614 bytes.
-var cuegenInstanceData = []byte("\x01\x1f\x8b\b\x00\x00\x00\x00\x00\x00\xff\xacW\xcdo\xd4H\x16\xb7CVZ[\uc7b8\"=\x8c\xb4b#\xd6\x11\a\x04j)B@`\x95\u02f2\x1a1'\x84\xa2j\xfb\xb9\xbb\x06\xbb\xcaSU\x86D\xa4\x0f3\xc30\xf3W\u04e3WU\xfel\xf3\x91\x99\xe4\x92\xf6\xfb\xaa\xf7~\xf5\xbe\xea\x1f\xdb\xdf\xf6\u00bd\xed\xefA\xb8\xfd9\b\x1el\u007f\xba\x16\x86\u05f9\u0406\x89\f\x8f\x99aD\x0f\xaf\x85\xfb\xdfIi\u00bd \xdc\xff?3\xeb\xf0z\x10\xfe\xed9/Q\x87\u06cfA\x10\xdc\xdc\xfe\xba\x17\x86\xff|\xf5:k0-x\xe95?\x06\xe1\xf6C\x10\xdc\xd9\xfer-\f\xff\xde\xd3?\x04\xe1^\xb8\xff?V!\x19\u06b7\xc48\b\x82O7n\x92'a\xb8\x17\x86\x919\xafQ\xa7Y\x83\xe1\xa7\x1b\xfb5\xcb\u07b0\x15\u00b2\xe1e\x1e\u01c7\x87\xf0\x18\xe8|\u0224R\xa8k)r\rF\x02\x83\xffJ'\x94\x12;\x8do\u04ff\x05\xbc\x8f#:^\xb0\n\x17\xe0\xff\xb4Q\\\xac\xe2\bE&s.V\x1d\xe3\xf63O\x89#.\f\xaaZ\xa1a\x86K\xf1h\x01\xb7OF\x948*\xa4\xaa\x1eu\xaa\xa4\xfd\\\xaa*\x8e\f[\xe9G\xf6\xe0\xe8\x95;\xe9\xf5\xa2;r\x13ol\x10\xc7X\xb0\xa64\xc05\x985\x02\xb9\b\x8d\xc6\x1c\n\xa9@\x9b\x9c\v`\"\xa7_\xb21)\xbc\\#h4\x86\x8b\x95\x86\x1ck\x149Y\x91\xa2\u05eedNQ{\xc3\xf6|\v\xc10\xfe\x83\xe4?\t\\\xb4\xcel\x06p\x9e\x88BB\x8e\x05\x17\xa8a-\xdf\x01sV\xb9\x06\x8b\x12\xe6\u059f\x0e\x15\xcc=\u00a48<,g\x86\xf5\xa0\x1c\x18\xd5 \\@\xc1J\x8dq\xa4\xb0@\x85\"C\xbd\xd8ef\xe7Y\xe9\x183\x9a\xd65N\xc0\x93\xc4R\xca2\x8edM\u07ect*\x8e\x96I\xa1\x8db\\\x98^\xee\rb\xeda\xd1\vO\xe3\"\x93U]\xa2\xb1Y\xe1iU-\x95i=p4m\x14\xb2\xaau\xca\xd1r\x99\xe9>DGc\xc6(\xbel\x8c\v\xc0\xd2\x1c\xbct-\x9a\xee\x8e\xee\xcd\xf9`\xef8\xe7\x85\xc5\u0080\xacQ1\x17\x89\x93N\xe3\xc3CR}\xb9F\x8d`\xb0\xaaKfP\x03Sh/@\xd0m\x18\tK\x84F\xf0\x82#\xdd\v0csAIi@\x16`\xd6\\\x93\x91L\x8a\x82\xaf\x1awB\x1a\xdb\x03\xec}qQ7.M\x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\xa8S\u007fs\xffm\xedN^\xa4\xe4\xf3\x0e\xe6\xf3X\u007f\u045b\t\x8e\xf3\xf8\xcd\xe3\xd6\xc73j\xcd:\xb51\fb\xbbu\u0527P\xfb:\x1e*\x0f\xdb7m\u012b).\xb7\x8e|\xb7\x1f{\u06fa5z\x8ewq\r\x9f\xe1\xb3\x01\xcc\xe2\xd2\xf9\xb5\x89\xc7Kb7J\xda\"\xe8#\xe8\aI\xbf\xd3O\xaa\xc5\x15\t\\\xb4\xf76\xdch[?\x86\x8blo\xbc\x9f2cpGnP\x19:\xcb\xe3\xc15\xebO'\xd8O\x8fY\xb9\xde\a#\xab/\x19\xec\x05\a3oR8\xf3#\xb0\x9f\x1c\x13\xf1\x1d\u04dbx\xdcn/\xd1\xf2\xec\x96\xedf\xc9\xf8\x94\xe9p\xf8\xac\xcb_\x1c\x03\u07ea\xb5\x89\x83\xe0\x8f\x00\x00\x00\xff\xff\f\x84\x01\v\xad\x14\x00\x00")
+// Data size: 1623 bytes.
+var cuegenInstanceData = []byte("\x01\x1f\x8b\b\x00\x00\x00\x00\x00\x00\xff\xacW\xddo\xd4H\x12\xb7CN:\xb7\xb8\x93N\xe2\xf5\xa4\xc2H\x88\x8b8G< \xd0H\x11\x02\x02\xa7\xbc\x1c\xa7\x13\xfb\x84P\xd4c\x97gz\xb1\xbb\xbd\xee6$\"\xf3\xb0\xbb,\xbb\u007f5\xb3\xaa\xee\xf6\u760f\xec&/\x19\xd7WWU\xf7\xaf>\xfe\xb6\xfdu/\xdc\xdb\xfe\x16\x84\u06df\x82\xe0\xc1\xf6\xc7kax]Hm\xb8L\xf1\x98\x1bN\xf4\xf0Z\xb8\xff\u007f\xa5L\xb8\x17\x84\xfb\xff\xe3f\x1d^\x0f\u00bf<\x17\x05\xeap\xfb1\b\x82\u007fn\u007f\xd9\v\u00ff\xbfz\x9d6\x98\xe4\xa2\xf0\x9a\x1f\x83p\xfb!\b\xeel\u007f\xbe\x16\x86\u007f\xed\xe9\x1f\x82p/\xdc\xff//\x91\f\xed[\"\v\x82\xe0\u04cd\x03\xf2$\f\xf7\xc202\xe7\x15\xea$m0\xfct\xe3\x1f\x15O\xdf\xf0\x15\u00b2\x11E\xc6\xd8\xe1!<\x06:\x1fRU\u05e8+%3\rF\x01\x87\xff('\x94\x10;a\xb7\xe8\xdf\x02\u07b3\x88\x8e\x97\xbc\xc4\x05\xf8?mj!W,B\x99\xaaL\xc8U\u01f8\xf5\xccSX$\xa4\xc1\xba\xaa\xd1p#\x94|\xb4\x80['#\n\x8brU\x97\x8f:U\xd2~\xae\xea\x92E\x86\xaf\xf4#{p\xf4\u029d\xf4z\xd1\x1d\xb9a\x1b\x1b\xc41\xe6\xbc)\f\b\rf\x8d@.B\xa31\x83\\\u0560M&$p\x99\xd1/\u0558\x04^\xae\x114\x1a#\xe4JC\x86\x15\u028c\xac(\xd9k\x97*\xa3\xa8\xbd\xe1\x05\xd8\xf8\xe1\xf68\x01\a\xf1\xbfc\xb8h\xbd\xd9\f\xf2y\"s\x05\x19\xe6B\xa2\x86\xb5z\a\u0719\x15\x1al\x9a0\xb3\x0eui\xc1\u0327\x98\x14m\xb4\xf6\x8bE\x197\xbc\xcf\u0281\xa9\x1b\x84\v\xc8y\xa1\x91E5\xe6X\xa3LQ/v\x99\xe9yZ8\u018c\xa6uMP\xe6Ib\xa9T\xc1\"U\xd17/\x9c\x8a\xa3\xa5JjSs!M/\xf7\x06\xb1\xf2y\xd1\vO\x132UeU\xa0\xb1\xcf\xc2\xd3\xcaJ\u0566\xf5\xc0\u0474\xa9\x91\x97\xadS\x8e\x96\xa9T\xf7!:\x1a7\xa6\x16\xcb\u01b8\x00,\u0365\x97\xeeE\xd3\xe5\xd1\xc59\x1f\xec%g\"\xb7\xb90\xa0*\xac\xb9\x8b\xc4I'\xec\xf0\x90T_\xaeQ#\x18,\xab\x82\x1b\xd4\xc0k\xb4\x17 \xe96\x8c\x82%B#E.\x90\xee\x05\xb8\xb1\x8f\xa1V\u0280\xca\xc1\xac\x85&#\xa9\x92\xb9X5\ue104\xd9\x03\xec}\tY5\u01bd\xd3\xfe\xd5\xd0\xd7\x00\x17\aq\xda \xbd\x98S\xa2'I\u00a2h\u00e2\xa8@\x03gp\xe4\u0107\xe9\x98\xdcZ4\xca\u02d4I\x96\x06o\xe8\x8c\xf5Gk\xefJ\xda\u042b%\xa8\xe9D\xa7k,\xb9w\x86t\xf1\u0320\xd4\xeeIX\xe98\xf9^+\x19\xfb\xaf\t\x86)\x1a\xde\x18\u0545\xb3q*\xe7\xbc,.\xabr9\x8d\r\xe1>\xc23z]_M\xb8\x8d\xe03\x19?\xbd7\x97s\x9f\u0543\u065cO\x99\u04dc\x9f\xde\xfbJ\xd6\t\xcf}\xce7,RMe\u0687\xe3\xbczx\xff\xea\xddzx\xff\xb2~\xe1[\xaa\x04\u007f\xfc9\x9f>y|\xf5a<y\xfc\x950rA\xb0\x1f\u0191a\xfe\xa7\u00b8\xff\xe0\xe9\xc3+\x87\xa6\xb5zI|\xb6\xbd\xeeY\vS(y\xa5][\xe9\xa1K\x85\xcc\x17F\u01eaj*\x88FP\x1d\x9c <\x8e\xbb\xb2{\u02a2\x98f\x04G\xa1\x9eK_\xac/\x01\x9eH_-\x95@\xdbS\v\"\x17\x99\x17\x1f\x93\xe5<\u0657\no\x84\xbeXW\r\xa6Tsf\x06T\x83g\x86\xa8+\xe5C\xb0\u0515\"ZU+\xa3:\xd7\xec\x17\x8b\xa8\xfc\xbf8~\xb1\x00:\\\xe3\x0fw-)\xb6\x86Z\x85\xcer\xb5\xf4\xdcj\xd9g\xc8r\x97BV\u02ee\u0477\xe3\r\b\x99\x89\xd4\xf5\x14\x97t\xbaAnlc\xaa\xb1\xaaQ\xa3\xa4a\x038]\u01ea\xe6e\u00ba\xe1h\x017\x8f\xe2\u0619\x940\x1e\x8b C\x83u9\x98\"R\xac\r\x17\xb2\xb5\x03z\xad\x9a\"\xa3\xde5\x9a%\x0e\x0f\u1e6a\xa1\x1d@\xef\x82\xc5w\xc9\xcf'\x92\xc0\xa9\x8f\xea\xb4\x16K\xe7\x9f{uw\xe1\xddZ\xa4k\x10Fc\x91\u06fe\xc7%\xa9\xa6J\xbe\xc5\u06b8\x86\xc9\xe1\xe9w\u03fcF\xc2&\x13]7\xa4\xd99n8\xd8yzn\a\xca\xd1\xc0\xd7\x0eN\x931+\u0395r\xef\u040d\x89N+v\a\xc7\xfe:\xe8~\x1c\"RU\x964\\\x15B\xa2#\x1b\xb5\x8b\x05bX\x1483\x0e\x80\xcezg\x99`\xb7\xaay\xb5\x1eq-\xc513\xbe\x1a\xb12\xbej\x19\x86O8\xc6\x1b\xb4\x18\u007f\u03c6\x15\xc8\x16 \u02e4(w\xb8>t\xcf.f\xf9\x85\x13 \xb8\xec\xf0-\xce,\xdb>\xf5\x1d\xbe\x03\x80\x15\xa0g\xef \x10/\xa0\xabN=L\x9c\x84\x85\x01A\xa3\x97 \x92\x13 \u065d#\x88\x18w\u0670\xd7\xd7gd\xb5\xe3\x92\xfb\x8biP&\xad\xe9P\x10\x13\xb1\xbb\xc0(*\xb8=dEA\xf8\xb2O\xaaWb\xb5]5\xbc]\x9aF\x1c\u007fG\xdd\x0e*3\a\x8e\x86\x10\u007f\x89\xc3G\xb7c\xa8\x17\xf8\x16s\xaaB\xc9+\xf1\x19[\x9e\xfb\r\x86\x1c\x8cl\xef\xe96\x17\u07c3\xa8\x8e\xf1\xa2p\xcc\x04N\fd\n5He@\u0234h2t\x8b\x93\xaaK89N\x98\x95\xb3\x0e\u0675\x8d\x16\u0523nw\xeb`n\xbd\xa7\x1et:\a\xc2n\xe5i\xd1\b\x17\x10\xdb\xf6n\u007f\xb5 \x9cl\x14\xd3\tb\xbc\x97L\xdb\xf2x\v\x9ar\xc7\xfb\u041d\x11\xfb_p{Ja\xd1d[\x9a\xda\x1b\xefMS\xeex[\x9ap7T\x0ee;\x90\r\u70dd|\xf9\x1c\xed\x9c7\x1fUo\u007f\xa7\xce\xf5\x17\xe0rMY\xa7\xfa\xe6\xfe[\xecN\xb6S\xf2y'\xe7\xf3\xb9\xfe\xa27\x93<\xce\xe7o>o}<\xa3\u04ac\x13\x1b\xc3 \xb6\x9bG\xfd\x13j7\xe5\xa1\xf2\xb0|\xd3t\xbc\x9a\xe6\xe5\u646f\xf6co[\xb7F\xaby\x17\xd7p%\x9f\r`6/\x9d_\x1b6\x1e\x18\xbbV\u0482\xa0\x8f\xa0o$\xfd|?A\x8b\x03\t\\\xb4\xf76\x9cn[?\x86Cmo\xbc\xef2\xe3\xe4\x8e\xdc \x18:\xcb\xe3\xc65\xebO'\xd8w\x8fY\xb9\xde\a\xa3\xca/\x19\xec\x05\a=o\x02\x9c\xf9\x16\xd8w\x8e\x89\xf8\x8e\xe9\r\x1b\x97\xdbK\x94<;q\xbb^2>e\xda\x1c>\xeb\xf2\x17\xdb\xc0\xb7jmX\x10\xfc\x1e\x00\x00\xff\xffB\xee2\xf0\xba\x14\x00\x00")
diff --git a/pkg/tool/http/pkg.go b/pkg/tool/http/pkg.go
index 5969e73..d211080 100644
--- a/pkg/tool/http/pkg.go
+++ b/pkg/tool/http/pkg.go
@@ -19,20 +19,16 @@
 var pkg = &internal.Package{
 	Native: []*internal.Builtin{},
 	CUE: `{
-	Get: {
-		Do
+	Get: Do & {
 		method: "GET"
 	}
-	Post: {
-		Do
+	Post: Do & {
 		method: "POST"
 	}
-	Put: {
-		Do
+	Put: Do & {
 		method: "PUT"
 	}
-	Delete: {
-		Do
+	Delete: Do & {
 		method: "DELETE"
 	}
 	Do: {