internal/core/compile: fix let cycle error

Method was not marked with a '*', causing error
to be lost.

Fixes #1042

Change-Id: I600940fe933c7122c7f2e06b97542cb44655d5ae
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/10001
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>
diff --git a/cue/testdata/compile/let.txtar b/cue/testdata/compile/let.txtar
index 1c008d3..303ab71 100644
--- a/cue/testdata/compile/let.txtar
+++ b/cue/testdata/compile/let.txtar
@@ -57,6 +57,8 @@
     }
 }
 -- out/compile --
+b.let[]: cyclic references in let clause or alias:
+    ./in.cue:10:13
 --- in.cue
 {
   a: {
@@ -92,60 +94,5 @@
   }
 }
 -- out/eval --
-Errors:
 b.let[]: cyclic references in let clause or alias:
     ./in.cue:10:13
-
-Result:
-(_|_){
-  // [eval]
-  a: (struct){
-    b: (int){ 5 }
-    c: (int){ 5 }
-  }
-  b: (_|_){
-    // [eval]
-    b: (_|_){
-      // [eval] b.let[]: cyclic references in let clause or alias:
-      //     ./in.cue:10:13
-    }
-    c: (int){ 5 }
-  }
-  fieldOffset: (struct){
-    a: (struct){
-      p1: (struct){
-        x: (struct){
-          value: (int){ 2 }
-        }
-      }
-      p2: (struct){
-        x: (struct){
-          value: (int){ 2 }
-        }
-      }
-    }
-    b: (struct){
-      p1: (struct){
-        x: (struct){
-          x: (struct){
-            y: (int){ 2 }
-          }
-        }
-      }
-      p2: (struct){
-        x: (struct){
-          x: (struct){
-            y: (int){ 2 }
-          }
-        }
-      }
-    }
-  }
-  issue767: (struct){
-    #Foo: (#struct){
-      out: (#struct){
-        x: (string){ "" }
-      }
-    }
-  }
-}
diff --git a/cue/testdata/references/let.txtar b/cue/testdata/references/let.txtar
index dc4eaaa..e11c71a 100644
--- a/cue/testdata/references/let.txtar
+++ b/cue/testdata/references/let.txtar
@@ -64,7 +64,57 @@
     }
 }
 
+cycles: {
+  a: {
+    let A = { c: B }
+    let B = A
+    out: A
+  }
+
+  b: {
+    let A = { c: B }
+	  let B = { A.c }
+	  out: A
+  }
+
+  issue1042: {
+    #FullAdder: {
+      // IN
+      a: bool
+      b: bool
+      c: bool
+      // OUT
+      sum: bool
+      carry: bool
+    }
+
+    #Add16: {
+      a:   [bool] * 16
+      b:   [bool] * 16
+      out: [bool] * 16
+
+      let fulladders = [
+        for i in list.Range(0, 4, 1) {
+          #FullAdder & {"a": a[i], "b": b[i], c: carries[i]}
+        }
+      ]
+      let carries = [
+        false,
+        for i in list.Range(0, 4, 1) { fulladders[i].carry }
+      ]
+      out: [
+        for i in list.Range(0, 4, 1) { fulladders[i].sum }
+      ]
+    }
+  }
+}
 -- out/compile --
+cycles.a.let[].c.c: cyclic references in let clause or alias:
+    ./in.cue:68:18
+cycles.b.let[].c.c: cyclic references in let clause or alias:
+    ./in.cue:74:18
+cycles.issue1042.#Add16.let[].for[].c.for[].for[].c: cyclic references in let clause or alias:
+    ./in.cue:97:50
 --- in.cue
 {
   a1list: [
@@ -183,103 +233,44 @@
       if (〈import;list〉.max < 0) {}
     }
   }
-}
--- out/eval --
-(struct){
-  a1list: (#list){
-    0: (int){ 1 }
-  }
-  a1: (int){ 101 }
-  a2list: (#list){
-    0: (int){ 2 }
-  }
-  a2: (struct){
-    b: (int){ 202 }
-  }
-  a3list: (#list){
-    0: (int){ 3 }
-  }
-  a3: (struct){
-    b: (struct){
-      c: (int){ 303 }
+  cycles: {
+    a: {
+      out: 〈0;let A〉
     }
-  }
-  a4list: (#list){
-    0: (int){ 4 }
-  }
-  a4: (#list){
-    0: (struct){
-      v: (int){ 404 }
+    b: {
+      out: 〈0;let A〉
     }
-  }
-  a5list: (#list){
-    0: (int){ 5 }
-  }
-  a5: (struct){
-    b: (#list){
-      0: (struct){
-        v: (int){ 505 }
+    issue1042: {
+      #FullAdder: {
+        a: bool
+        b: bool
+        c: bool
+        sum: bool
+        carry: bool
       }
-    }
-  }
-  a6list: (#list){
-    0: (int){ 6 }
-  }
-  a6: (struct){
-    b: (struct){
-      c: (#list){
-        0: (struct){
-          v: (int){ 606 }
-        }
+      #Add16: {
+        a: ([
+          bool,
+        ] * 16)
+        b: ([
+          bool,
+        ] * 16)
+        out: ([
+          bool,
+        ] * 16)
+        out: [
+          for _, i in 〈import;list〉.Range(0, 4, 1) {
+            〈2;let fulladders〉[〈1;i〉].sum
+          },
+        ]
       }
     }
   }
-  a7list: (#list){
-    0: (int){ 7 }
-  }
-  a7: (struct){
-    v: (int){ 707 }
-  }
-  a8list: (#list){
-    0: (int){ 8 }
-  }
-  a8: (struct){
-    b: (struct){
-      v: (int){ 808 }
-    }
-  }
-  a9list: (#list){
-    0: (int){ 9 }
-  }
-  a9: (struct){
-    b: (struct){
-      c: (struct){
-        v: (int){ 909 }
-      }
-    }
-  }
-  incompleteLet: (struct){
-    input: (#list){
-      0: (int){ 1 }
-      1: (int){ 2 }
-      2: (int){ 3 }
-      3: (int){ 4 }
-      4: (int){ 5 }
-    }
-    last: (struct){
-      min: (int){ 1 }
-      max: (int){ 5 }
-    }
-    bar: (struct){
-      min: (int){ 1 }
-      max: (_|_){
-        // [incomplete] incompleteLet.bar.max: undefined field: max:
-        //     ./in.cue:54:23
-      }
-    }
-    x: (_|_){
-      // [incomplete] incompleteLet.x: undefined field: max:
-      //     ./in.cue:61:17
-    }
-  }
 }
+-- out/eval --
+cycles.a.let[].c.c: cyclic references in let clause or alias:
+    ./in.cue:68:18
+cycles.b.let[].c.c: cyclic references in let clause or alias:
+    ./in.cue:74:18
+cycles.issue1042.#Add16.let[].for[].c.for[].for[].c: cyclic references in let clause or alias:
+    ./in.cue:97:50
diff --git a/internal/core/compile/compile.go b/internal/core/compile/compile.go
index 5cbd5d6..ab7b981 100644
--- a/internal/core/compile/compile.go
+++ b/internal/core/compile/compile.go
@@ -190,7 +190,7 @@
 }
 
 // lookupAlias looks up an alias with the given name at the k'th stack position.
-func (c compiler) lookupAlias(k int, id *ast.Ident) aliasEntry {
+func (c *compiler) lookupAlias(k int, id *ast.Ident) aliasEntry {
 	m := c.stack[k].aliases
 	name := id.Name
 	entry, ok := m[name]