cue: allow different names for key bindings in templates

Change-Id: I28c19fa72fcab1fc69fe4db31ae302e417ca72ec
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/2282
Reviewed-by: Marcel van Lohuizen <mpvl@google.com>
diff --git a/cue/ast.go b/cue/ast.go
index c0e93f8..797dc60 100644
--- a/cue/ast.go
+++ b/cue/ast.go
@@ -445,11 +445,14 @@
 			break
 		}
 
-		label := v.label(n.Name, true)
+		f := v.label(n.Name, true)
 		if n.Scope != nil {
 			n2 := v.mapScope(n.Scope)
+			if l, ok := n2.(*lambdaExpr); ok && len(l.params.arcs) == 1 {
+				f = 0
+			}
 			value = &nodeRef{baseValue: newExpr(n), node: n2}
-			value = &selectorExpr{newExpr(n), value, label}
+			value = &selectorExpr{newExpr(n), value, f}
 		} else {
 			n2 := v.mapScope(n.Node)
 			value = &nodeRef{baseValue: newExpr(n), node: n2}