]> Cypherpunks repositories - gostls13.git/commitdiff
bug123
authorRuss Cox <rsc@golang.org>
Tue, 17 Feb 2009 01:44:05 +0000 (17:44 -0800)
committerRuss Cox <rsc@golang.org>
Tue, 17 Feb 2009 01:44:05 +0000 (17:44 -0800)
R=ken
OCL=25075
CL=25075

src/cmd/gc/lex.c
src/cmd/gc/walk.c
test/fixedbugs/bug123.go [moved from test/bugs/bug123.go with 87% similarity]
test/golden.out

index 78394b89b43752bd6323ab77d543d03b6b1fe415..a0fb124f3f7079031e19dee422a690444d277771 100644 (file)
@@ -1233,6 +1233,9 @@ lexinit(void)
                s->otype = t;
        }
 
+       /* for walk to use in error messages */
+       types[TFUNC] = functype(N, N, N);
+
        /* pick up the backend typedefs */
        belexinit(LBASETYPE);
 
index f3a3bd6e55aadc715bf4ea869b252c9e18559386..7175f077095daf0343add6538c4730d24182615a 100644 (file)
@@ -373,9 +373,12 @@ loop:
                if(n->type != T)
                        goto ret;
 
-               walktype(n->left, Erv);
                if(n->left == N)
                        goto ret;
+
+               walktype(n->left, Erv);
+               convlit(n->left, types[TFUNC]);
+
                t = n->left->type;
                if(t == T)
                        goto ret;
@@ -472,6 +475,7 @@ loop:
                        if(cr == 1) {
                                // a,b,... = fn()
                                walktype(r, Erv);
+                               convlit(r, types[TFUNC]);
                                l = ascompatet(n->op, &n->left, &r->type, 0);
                                if(l != N)
                                        indir(n, list(r, reorder2(l)));
@@ -3108,6 +3112,7 @@ multi:
        case OCALLINTER:
        case OCALL:
                walktype(nr->left, Erv);
+               convlit(nr->left, types[TFUNC]);
                t = nr->left->type;
                if(t != T && t->etype == tptr)
                        t = t->type;
similarity index 87%
rename from test/bugs/bug123.go
rename to test/fixedbugs/bug123.go
index 0576de37d6cf7fc41919d6c6615ab7dbee5e7a38..f26a0463695b5f849dedaa4460d8b9680dfdb6e6 100644 (file)
@@ -7,7 +7,7 @@
 package main
 const ( F = 1 )
 func fn(i int) int {
-  if i == F() {                // ERROR "function"
+  if i == F() {                // ERROR "func"
     return 0
   }
   return 1
index 89df568b89ff1548b6d9bf289986c4621e26223d..e251a708fd233024b1e5459dc39f2745b5234e57 100644 (file)
@@ -143,9 +143,6 @@ BUG: should compile
 =========== bugs/bug122.go
 BUG: compilation succeeds incorrectly
 
-=========== bugs/bug123.go
-BUG: errchk: command succeeded unexpectedly:  6g bugs/bug123.go
-
 =========== bugs/bug125.go
 BUG: errchk: command succeeded unexpectedly:  6g bugs/bug125.go