internal/core/comple: drop support for old-style aliases

These are still parsed, which:
1) will allow cue fix to work for now
2) allow the parsing to be coopted for aliases to embeddings.

Catches a few cases where the old syntax was still used.

Change-Id: I8b9504d824e271d6744851c61fe2651ace38496e
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/9503
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>
diff --git a/cue/testdata/compile/scope.txtar b/cue/testdata/compile/scope.txtar
index 76d1dcf..168d5c5 100644
--- a/cue/testdata/compile/scope.txtar
+++ b/cue/testdata/compile/scope.txtar
@@ -26,7 +26,7 @@
 {X=["foo"]: b: X | null}
 {[Y="bar"]: b: Y}
 
-B = {open: int}
+let B = {open: int}
 f: B
 
 schema: {
diff --git a/cuego/examples_test.go b/cuego/examples_test.go
index daa7604..44bf953 100644
--- a/cuego/examples_test.go
+++ b/cuego/examples_test.go
@@ -60,7 +60,7 @@
 	}
 
 	err := cuego.Constrain(&Config{}, `{
-		jsonFile = =~".json$"
+		let jsonFile = =~".json$"
 
 		// Filename must be defined and have a .json extension
 		Filename: jsonFile
diff --git a/doc/tutorial/kubernetes/manual/services/mon/alertmanager/configmap.cue b/doc/tutorial/kubernetes/manual/services/mon/alertmanager/configmap.cue
index c834813..404afc4 100644
--- a/doc/tutorial/kubernetes/manual/services/mon/alertmanager/configmap.cue
+++ b/doc/tutorial/kubernetes/manual/services/mon/alertmanager/configmap.cue
@@ -4,7 +4,7 @@
 
 configMap: alertmanager: {
 	"alerts.yaml": yaml.Marshal(alerts_yaml)
-	alerts_yaml = {
+	let alerts_yaml = {
 		receivers: [{
 			name: "pager"
 			// email_configs:
@@ -12,9 +12,9 @@
 			slack_configs: [{
 				channel: "#cloudmon"
 				text: """
-		{{ range .Alerts }}{{ .Annotations.description }}
-		{{ end }}
-		"""
+					{{ range .Alerts }}{{ .Annotations.description }}
+					{{ end }}
+					"""
 				send_resolved: true
 			}]
 		}]
diff --git a/doc/tutorial/kubernetes/manual/services/mon/prometheus/configmap.cue b/doc/tutorial/kubernetes/manual/services/mon/prometheus/configmap.cue
index 6434221..3ed994f 100644
--- a/doc/tutorial/kubernetes/manual/services/mon/prometheus/configmap.cue
+++ b/doc/tutorial/kubernetes/manual/services/mon/prometheus/configmap.cue
@@ -4,7 +4,7 @@
 
 configMap: prometheus: {
 	"alert.rules": yaml.Marshal(alert_rules)
-	alert_rules = {
+	let alert_rules = {
 		groups: [{
 			name: "rules.yaml"
 			rules: [{
@@ -44,7 +44,7 @@
 		}]
 	}
 	"prometheus.yml": yaml.Marshal(prometheus_yml)
-	prometheus_yml = {
+	let prometheus_yml = {
 		global: scrape_interval: "15s"
 		rule_files: ["/etc/prometheus/alert.rules"]
 		alerting: alertmanagers: [{
diff --git a/internal/core/compile/compile.go b/internal/core/compile/compile.go
index 1d86bd4..eefe2af 100644
--- a/internal/core/compile/compile.go
+++ b/internal/core/compile/compile.go
@@ -410,7 +410,7 @@
 
 	switch n.Node.(type) {
 	// Local expressions
-	case *ast.LetClause, *ast.Alias:
+	case *ast.LetClause:
 		entry := c.lookupAlias(k, n)
 
 		return &adt.LetReference{
@@ -419,6 +419,8 @@
 			Label:   label,
 			X:       entry.expr,
 		}
+
+		// TODO: handle new-style aliases
 	}
 
 	if n.Scope == nil {
@@ -507,12 +509,7 @@
 		c.insertAlias(x.Ident, a)
 
 	case *ast.Alias:
-		a := aliasEntry{
-			label:   (*deprecatedAliasScope)(x),
-			srcExpr: x.Expr,
-			source:  x,
-		}
-		c.insertAlias(x.Ident, a)
+		c.errf(x, "old-style alias no longer supported: use let clause.\nuse cue fix to update.")
 	}
 }
 
@@ -609,7 +606,8 @@
 		}
 
 	// Handled in addLetDecl.
-	case *ast.LetClause, *ast.Alias:
+	case *ast.LetClause:
+	// case: *ast.Alias:
 
 	case *ast.CommentGroup:
 		// Nothing to do for a free-floating comment group.
@@ -648,9 +646,7 @@
 		c.updateAlias(x.Ident, expr)
 
 	case *ast.Alias:
-		// TODO(legacy): deprecated, remove this use of Alias
-		expr := c.labeledExpr(nil, (*deprecatedAliasScope)(x), x.Expr)
-		c.updateAlias(x.Ident, expr)
+		c.errf(x, "old-style alias no longer supported: use let clause.\nuse cue fix to update.")
 	}
 }
 
diff --git a/internal/core/compile/label.go b/internal/core/compile/label.go
index d35b7c0..5d02662 100644
--- a/internal/core/compile/label.go
+++ b/internal/core/compile/label.go
@@ -145,11 +145,3 @@
 	// TODO: include more info in square brackets.
 	return "let[]"
 }
-
-// TODO(legacy): remove
-type deprecatedAliasScope ast.Alias
-
-func (l *deprecatedAliasScope) labelString() string {
-	// TODO: include more info in square brackets.
-	return "let[]"
-}